package cn.fl.project.controller;

import cmm.comm.facade.framework.api.ISysDictionaryApiService;
import cmm.comm.facade.framework.dto.SysDictionaryDTO;
import cmm.comm.facade.upload.api.ISysUlDatCfgDtlApiService;
import cmm.comm.facade.upload.api.IUploadApiService;
import cmm.comm.facade.upload.condition.SysUlDatCfgDtlQueryCondition;
import cmm.comm.facade.upload.condition.SysUlDatCfgQueryCondition;
import cmm.comm.facade.upload.condition.SysUlFilesRecQueryCondition;
import cmm.comm.facade.upload.constant.UploadConstant;
import cmm.comm.facade.upload.dto.SysUlDatCfgDTO;
import cmm.comm.facade.upload.dto.SysUlDatCfgDtlDTO;
import cmm.comm.facade.upload.dto.SysUlFilesRecDTO;
import cmm.mid.core.framework.dto.DataResultDTO;
import cmm.mid.core.framework.page.DataResultVO;
import cmm.mid.core.framework.page.KeyValueVO;
import cmm.mid.core.framework.page.ListPageVO;
import cmm.mid.core.framework.page.Pager;
import cmm.web.core.framework.controller.BaseController;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.logger.eum.LogExceptionEnum;
import cn.cmm.base.framework.logger.eum.LogOperEnum;
import cn.cmm.base.framework.utils.*;
import cn.cmm.cache.framework.utils.PropertiesCacheUtils;
import cn.fl.capital.constant.CapitalConstant;
import cn.fl.customer.service.ICstBscInfoService;
import cn.fl.customer.vo.CstBscInfoVO;
import cn.fl.customer.vo.CstValidCardInfoVO;
import cn.fl.framework.base.constant.WebBaseConstant;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.framework.constant.DictionaryConstant;
import cn.fl.hsj.service.IHsjQueryService;
import cn.fl.kingdeews.dto.KingDeeWsInfoDTO;
import cn.fl.npspl.service.ISplNpSocialRlService;
import cn.fl.product.service.IPrdBscInfoService;
import cn.fl.product.service.ISplRlPsnService;
import cn.fl.project.constant.PrjBscInfoConstant;
import cn.fl.project.constant.PrjPrdDtlConstant;
import cn.fl.project.service.IPrjBscInfoService;
import cn.fl.project.service.IPrjLnkCompOrgRService;
import cn.fl.project.service.IPrjLnkCompService;
import cn.fl.project.service.IPrjPrdPaySchDService;
import cn.fl.project.vo.*;
import cn.fl.riskctrl.service.IRskCtrlService;
import cn.fl.spl.service.ISplCommPropInfoService;
import cn.fl.spl.service.ISplOpLogRecService;
import cn.fl.spl.transform.SplCommPropInfoVOTransform;
import cn.fl.spl.vo.SplCommPropInfoVO;
import cn.fl.system.constant.SysLogConstant;
import cn.fl.system.service.ISysDictionaryService;
import cn.fl.system.vo.SysUlFilesRecVO;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import fl.constant.facade.framework.constant.BusinessIdConstant;
import fl.customer.facade.customer.api.ICustomerApiService;
import fl.customer.facade.customer.condition.CstCorpTeamQueryCondition;
import fl.customer.facade.customer.constant.CustomerConstant;
import fl.customer.facade.customer.dto.CstCorpTeamDTO;
import fl.flow.facade.flow.api.IFlowQueryApiService;
import fl.flow.facade.flow.condition.SysFlowSHQueryCondition;
import fl.flow.facade.flow.constant.FlowConstant;
import fl.flow.facade.flow.dto.SysFlowSHDTO;
import fl.riskctrl.facade.externalinterface.service.dto.TheWorstRcCstBscInfoResult;
import fl.riskctrl.facade.riskctrl.rccstchannelinfo.dto.RcCstChannelInfoDTO;
import fl.spl.facade.carsguar.api.ISplCarsGuarDtlInfoApiService;
import fl.spl.facade.carsguar.condition.SplCarsGuarDtlInfoQC;
import fl.spl.facade.carsguar.dto.SplCarsGuarDtlInfoDTO;
import fl.spl.facade.framework.constant.SplSystemConstant;
import fl.spl.facade.framework.enums.*;
import fl.spl.facade.lnkcomp.api.ILnkCompModDtlApiService;
import fl.spl.facade.lnkcomp.api.IPrjLnkCompQueryApiService;
import fl.spl.facade.lnkcomp.condition.LnkCompModDtlQC;
import fl.spl.facade.lnkcomp.condition.PrjLnkCompBkAccQC;
import fl.spl.facade.lnkcomp.condition.PrjLnkCompOrgRQC;
import fl.spl.facade.lnkcomp.condition.PrjLnkCompQueryCondition;
import fl.spl.facade.lnkcomp.constant.LnkCompConstant;
import fl.spl.facade.lnkcomp.constant.PrjLnkCompRelInfoConstant;
import fl.spl.facade.lnkcomp.dto.LnkCompModDtlDTO;
import fl.spl.facade.lnkcomp.dto.PrjLnkCompBkAccDTO;
import fl.spl.facade.spl.api.ISplCommPropInfoApiService;
import fl.spl.facade.spl.api.ISplKingDeeWsInfoService;
import fl.spl.facade.spl.condition.SplCommPropInfoQC;
import fl.spl.facade.spl.dto.SplCommPropInfoDTO;
import fl.spl.facade.splrate.api.ISplRateRelInfoQueryApiService;
import fl.spl.facade.splrate.condition.SplRateRelInfoQC;
import fl.spl.facade.splrate.constant.SplRateRelInfoConstant;
import fl.spl.facade.splrate.dto.SplRateRelInfoDTO;
import net.sf.json.JSONArray;
import org.apache.commons.collections.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import tc.relationmap.facade.relationmap.hsj.dto.HsjBasicDTO;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.text.DecimalFormat;
import java.util.*;
import java.util.Map.Entry;

/**
 * @Description: 挂靠公司表 控制层
 */
@Controller
@RequestMapping("/project/prjlnkcomp")
public class PrjLnkCompController extends BaseController {
    private static final Logger logger = LoggerFactory.getLogger(PrjLnkCompController.class);

    /**
     * PrjLnkComp 服务层BEAN
     */
    @Autowired
    private IPrjLnkCompService prjLnkCompService;
    @Autowired
    private IPrdBscInfoService prdBscInfoService;

    @Autowired
    private IPrjLnkCompOrgRService prjLnkCompOrgRService;
    @Autowired
    private IFlowQueryApiService flowQueryApiService;

    @Autowired
    private ICstBscInfoService cstBscInfoService;

    @Autowired
    private IPrjLnkCompQueryApiService prjLnkCompQueryApiService ;


    @Autowired
    private IPrjPrdPaySchDService prjPrdPaySchDService;
    
    @Autowired
	private ISysDictionaryApiService sysDictionaryApiService;
    
    @Autowired
	private ISplOpLogRecService splOpLogRecService;

    //2020-06-10 12:34:15 三方数据关停
    @Autowired
    private IHsjQueryService hsjQueryService ;

    @Autowired
    private IUploadApiService uploadApiService;

    @Autowired
    private ISysUlDatCfgDtlApiService sysUlDatCfgDtlApiService;

    @Autowired
    private ILnkCompModDtlApiService lnkCompModDtlApiService;
    
    @Autowired
    private ISysDictionaryService sysDictionaryService ;

    @Autowired
    private ISplRateRelInfoQueryApiService splRateRelInfoQueryApiService;

    @Autowired
    private ISplKingDeeWsInfoService iKingDeeWsInfoService;
    @Autowired
    private ISplNpSocialRlService splNpSocialRlService;
    @Autowired
    private ISplRlPsnService splRlPsnService;

    @Autowired
    private IRskCtrlService rskCtrlService;

    @Autowired
    private IPrjBscInfoService prjBscInfoService;

    @Autowired
    private ICustomerApiService customerApiService;

    @Autowired
    private ISplCommPropInfoApiService splCommPropInfoApiService ;
    @Autowired
    private ISplCarsGuarDtlInfoApiService splCarsGuarDtlInfoApiService ;
    /**
     * 到挂靠公司相关项目
     */
    @RequestMapping(value = "/lnkCompPrjInfo.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView lnkCompPrjInfo(HttpServletRequest request, HttpServletResponse response) {
        String id = request.getParameter("id");
        ModelAndView view = new ModelAndView("project/prjlnkcomp/prjLnkCompPrjInfo");
        view.addObject("id", id);
        BaseLogUtils.newWebLogger("到挂靠公司相关项目").setLogOperType(LogOperEnum.REQ)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                .setWarning(false)
                .setKeys("id", id)
                .info();
        return view;
    }

    /**
     * 到修改审核状态页面
     */
    @RequestMapping(value = "/toModifyAudStsCdPage.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView toModifyAudStsCdPage(HttpServletRequest request, HttpServletResponse response) {
        String id = request.getParameter("id");
        ModelAndView view = new ModelAndView("project/prjlnkcomp/prjLnkCompModifyAudSts");
        //审核状态
        List<KeyValueVO> searchAudStsCdList = this.prdBscInfoService.searchAudStsCdList();
        view.addObject("searchAudStsCdList", searchAudStsCdList);
        view.addObject("id", id);
        BaseLogUtils.newWebLogger("加载修改审核状态页面").setLogOperType(LogOperEnum.REQ)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                .setWarning(false)
                .setKeys("id", id)
                .info();
        return view;
    }

    /**
     * 到列表页面
     */
    @RequestMapping(value = "/toListPage.do", method = {RequestMethod.GET})
    public ModelAndView toListPage(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView view = new ModelAndView("project/prjlnkcomp/projectLnkCompList");
        List<KeyValueVO> keyValueList = prjLnkCompService.getAudStsCdList();
        List<KeyValueVO> orgCdList = prjLnkCompService.getOrgCdList();
        view.addObject("keyValueList", keyValueList);
        view.addObject("orgCdList", orgCdList);
        view.addObject("buOrgCd", CurrentThreadContext.getCurrentBuOrgCd());
        BaseLogUtils.newWebLogger("跳转到挂靠公司列表页面").setLogOperType(LogOperEnum.REQ)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                .setWarning(false)
                .info();
        return view;
    }

    /**
     * 到挂靠公司授信页面
     */
    @RequestMapping(value = "/toAddPrjLnkCompCrLimPage.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView toAddPrjLnkCompCrLimPage(HttpServletRequest request, HttpServletResponse response) {
        String compId = request.getParameter("lnkCompId");
        ModelAndView view = new ModelAndView("project/prjlnkcomp/prjLnkCompCrLimAddPage");
        Long currCrAmt = this.prjPrdPaySchDService.searchCurrLnkCompCrAmtByLnkId(Long.valueOf(compId));
        view.addObject("compId", compId);
        Integer isProvMgr = BaseConstant.IS_YESNO_NO;//是不是省总
        if (CurrentThreadContext.getCurrentRoleId().compareTo(PrjLnkCompRelInfoConstant.PRO_COMP_MGR_ROLE_ID) == 0) {
            isProvMgr = BaseConstant.IS_YESNO_YES;
        }
        view.addObject("isProvMgr", isProvMgr);

        view.addObject("currCrAmt", DecimalUtils.convertFenToYuan(currCrAmt));
        BaseLogUtils.newWebLogger("跳转到修改挂靠公司页面").setLogOperType(LogOperEnum.REQ)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                .setWarning(false)
                .setKeys("id", compId)
                .info();
        return view;
    }

    /**
     * 到修改页面
     */
    @RequestMapping(value = "/toModifyPage.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView toModifyPage(HttpServletRequest request, HttpServletResponse response) {
        String id = request.getParameter("id");
        String taskNm = request.getParameter("taskNm");
        ModelAndView view = new ModelAndView("project/prjlnkcomp/projectLnkCompAdd");
        if(StringUtils.isNotEmpty(taskNm) && "信审中心审核".equals(taskNm)){
            //2020-01-20 16:39:15 贺王泽modify 高蕾需求,信审审核页面支持信审修改,新增一个页面
            view = new ModelAndView("project/prjlnkcomp/projectLnkCompForXinShenAdd");
        }

        String hsjBasicId = request.getParameter("hsjBasicId");
        String lnkCompNm = request.getParameter("lnkCompNm");//公司名称
        String orgCode = request.getParameter("orgCode");// 组织机构代码
        String bizLicNo = request.getParameter("bizLicNo");//营业执照注册号
        String taxRegNo = request.getParameter("taxRegNo");//税务登记号
        String audStsCd = request.getParameter("audStsCd");
        String isFlow = request.getParameter("isFlow");
        String BuOrgCd = CurrentThreadContext.getCurrentBuOrgCd();
        String creditcode = request.getParameter("creditcode");// 统一社会信用代码
        String entType = request.getParameter("entType");// 企业类型
        String address = request.getParameter("address");// 注册地址
        String opendate = request.getParameter("opendate");// 成立日期
        String busiscope = request.getParameter("busiscope");// 经营范围
        String isLnkNmModify = request.getParameter("isLnkNmModify");
        String importDataSource = request.getParameter("importDataSource");
        String isShowRate = request.getParameter("isShowRate");

        if(StringUtils.isEmpty(id)){
            //从好数据或本地获取数据
            //2020-06-10 12:35:34 三方接口关停
            HsjBasicDTO hsjBasicDTO = this.hsjQueryService.getCommInfoByNameAndType(BaseConstant.IS_YESNO_YES_STR, lnkCompNm);
            if(null != hsjBasicDTO){
                creditcode = hsjBasicDTO.getCreditCode();
                entType = hsjBasicDTO.getEntType();
                address = hsjBasicDTO.getAddress();
                opendate = hsjBasicDTO.getOpenFrom();
                busiscope = hsjBasicDTO.getOperateScope() ;
            }
        }

        if (StringUtils.isEmpty(audStsCd) && StringUtils.isEmpty(id)) {
            audStsCd = FlowConstant.FLOW_CHECK_STATE_NON;
        }

        //请求来源，判断是否回调函数，空：不会掉
        String fromSrcBiz = request.getParameter("fromSrcBiz") ;
        //判断页面是否显示，提交按钮，1：显示，空或0：不显示
        String isOrSubmit = request.getParameter("isOrSubmit");

        //挂靠公司关联人员类型
        List<KeyValueVO> prjLnkCompRlRsnTypList = prjLnkCompService.getPrjLnkCompRlRsnTypList();

        //获取证件类型
        List<KeyValueVO> certTypCdList = prjLnkCompService.getCertTypCdList();
        view.addObject("certTypCdList", JSON.toJSONString(certTypCdList));
        view.addObject("rlRsnTypListJSON", JSON.toJSONString(prjLnkCompRlRsnTypList));
        PrjLnkCompVO prjLnkCompVO = null;
        String defCodNm = "";
        for (KeyValueVO keyValueVO : certTypCdList) {
            if (keyValueVO.getKey().equals(PrjLnkCompRelInfoConstant.CODE_CERT_TYP_DEF_CD)) {
                defCodNm = keyValueVO.getValue();
            }
        }
        
        //必填联系人类型
  		List<SysDictionaryDTO> mustAddRlPsnTypCds = this.sysDictionaryApiService.searchGroupAll(CurrentThreadContext.getCurrentSysCd(),CurrentThreadContext.getCurrentOrgCd(),DictionaryConstant.CODE__PRJ_LNK_COMP_RL_PSN_TYP_CD);
  		List<String> mustAddRlPsns = null ;
  		List<String> noAddRlPsns = null ;
  		if(CollectionUtils.isNotEmpty(mustAddRlPsnTypCds)){
  			mustAddRlPsns = new ArrayList<>(mustAddRlPsnTypCds.size());
            noAddRlPsns = new ArrayList<>(mustAddRlPsnTypCds.size());
  			for(SysDictionaryDTO dto : mustAddRlPsnTypCds){
  				if(BaseConstant.IS_YESNO_YES == dto.getIsSysDef()){
                    mustAddRlPsns.add(dto.getCode());
                }else if(2 == dto.getIsSysDef()){
                    noAddRlPsns.add(dto.getCode());
                }
  			}
  		}
  		view.addObject("mustAddRlPsnTypCdJSON", null == mustAddRlPsns ? null :JSON.toJSON(mustAddRlPsns));
  		view.addObject("noAddRlPsnTypCdJSON", null == noAddRlPsns ? null :JSON.toJSON(noAddRlPsns));

        List<KeyValueVO> keyValueList = prjLnkCompService.getOwnerCdList();
        List<PrjLnkCompRlPsnVO> list = new ArrayList<PrjLnkCompRlPsnVO>();
        Map<String, PrjLnkCompRlPsnVO> map = new HashMap<String, PrjLnkCompRlPsnVO>();
        if (CollectionUtils.isNotEmpty(prjLnkCompRlRsnTypList)) {
            //重要联系人类型不为其它时，保存到list中
            for (KeyValueVO keyValueVO : prjLnkCompRlRsnTypList) {
                if (!keyValueVO.getKey().equals(PrjLnkCompRelInfoConstant.CODE_RL_TYP_CD_5)
						&& (CollectionUtils.isNotEmpty(mustAddRlPsns) && mustAddRlPsns.contains(keyValueVO.getKey()) || CollectionUtils.isEmpty(mustAddRlPsns)) ) {
                    PrjLnkCompRlPsnVO rlPsnVO = new PrjLnkCompRlPsnVO();
                    rlPsnVO.setRlTypCd(keyValueVO.getKey());
                    rlPsnVO.setRlTypCdNm(keyValueVO.getValue());
                    rlPsnVO.setCertTypCd(PrjLnkCompRelInfoConstant.CODE_CERT_TYP_DEF_CD);
                    rlPsnVO.setCertTypCdNm(defCodNm);
                    rlPsnVO.setIsSysDef(BaseConstant.IS_YESNO_YES);
                    rlPsnVO.setIsVerify(BaseConstant.IS_YESNO_NO);
                    rlPsnVO.setIsDefault(BaseConstant.IS_YESNO_YES);
                    list.add(rlPsnVO);
                    map.put(keyValueVO.getKey(), rlPsnVO);
                }
            }
        }
        Collections.sort(list, new Comparator<PrjLnkCompRlPsnVO>() {

			@Override
			public int compare(PrjLnkCompRlPsnVO o1, PrjLnkCompRlPsnVO o2) {
				// TODO Auto-generated method stub
				return o2.getIsSysDef().compareTo(o1.getIsDefault());
			}
		});
        
        ListPageVO<PrjLnkCompRlPsnVO> listPage=new ListPageVO<PrjLnkCompRlPsnVO>(list, list.size());;
        //id 存在时为修改
        if (StringUtils.isNotBlank(id)) {
            //获取保存的联系人信息
            prjLnkCompVO = this.prjLnkCompService.selectPrjLnkCompByIdAndBuOrgCd(Long.valueOf(id));
            List<PrjLnkCompRlPsnVO> rlList = prjLnkCompVO.getRlPsnList();
            //将已经存在的联系人信息从list中删除
            if (rlList != null && rlList.size() >0) {
                for (PrjLnkCompRlPsnVO prjLnkCompRlPsnVO : rlList) {
                    if (map.containsKey(prjLnkCompRlPsnVO.getRlTypCd())) {
                        map.remove(prjLnkCompRlPsnVO.getRlTypCd());
                    }
                }
                for (Map.Entry<String, PrjLnkCompRlPsnVO> entry : map.entrySet()) {
                    rlList.add(entry.getValue());
                }
                listPage = new ListPageVO<PrjLnkCompRlPsnVO>(rlList, rlList.size());
            }

            if(prjLnkCompVO.getExpDt() != null){
                prjLnkCompVO.setExpDtStr(DateUtils.formatDateToString(prjLnkCompVO.getExpDt(),DateUtils.YYYY_MM_DD));
            }

            if(prjLnkCompVO.getRegDt() != null){
                prjLnkCompVO.setRegDtStr(DateUtils.formatDateToString(prjLnkCompVO.getRegDt(),DateUtils.YYYY_MM_DD));
            }
            SplCommPropInfoQC splCommPropQC = new SplCommPropInfoQC();
            splCommPropQC.setIsValid(BaseConstant.IS_YESNO_YES);
            splCommPropQC.setPropTypCd("002");
            splCommPropQC.setIsDel(BaseConstant.IS_YESNO_NO);
            splCommPropQC.setDataId(Long.valueOf(id));
            List<SplCommPropInfoDTO> commPropInfoDTOList = this.splCommPropInfoApiService.searchList(splCommPropQC);
            if(CollectionUtils.isNotEmpty(commPropInfoDTOList)){
                String propinfo = "" ;
                for (SplCommPropInfoDTO commPropInfoDTO:commPropInfoDTOList) {
                    propinfo +=commPropInfoDTO.getPropInfo();
                    propinfo+=";";
                }
                prjLnkCompVO.setPropCd(propinfo.substring(0,propinfo.length()-1));
                SplCarsGuarDtlInfoQC carsGuarQC = new SplCarsGuarDtlInfoQC();
                carsGuarQC.setIsValid(BaseConstant.IS_YESNO_YES);
                carsGuarQC.setIsDel(BaseConstant.IS_YESNO_NO);
                carsGuarQC.setLnkId(Long.valueOf(id));
                List<SplCarsGuarDtlInfoDTO> carsGuarDTOList = this.splCarsGuarDtlInfoApiService.searchList(carsGuarQC);
                if(CollectionUtils.isNotEmpty(carsGuarDTOList)){
                    SplCarsGuarDtlInfoDTO carsGuarDtlInfoDTO = carsGuarDTOList.get(0);
                    prjLnkCompVO.setValidTmStar(carsGuarDtlInfoDTO.getValidTmStar());
                    prjLnkCompVO.setValidTmEnd(carsGuarDtlInfoDTO.getValidTmEnd());
                    prjLnkCompVO.setStopTruckRate(carsGuarDtlInfoDTO.getStopTruckRate());
                    prjLnkCompVO.setRoadBicycleRate(carsGuarDtlInfoDTO.getRoadBicycleRate());
                }
            }
        } else {
            prjLnkCompVO = new PrjLnkCompVO();
            prjLnkCompVO.setLnkCompNm(lnkCompNm);
            prjLnkCompVO.setOrgCode(orgCode);
            prjLnkCompVO.setBizLicNo(bizLicNo);
            prjLnkCompVO.setTaxRegNo(taxRegNo);
            if (StringUtils.isNotEmpty(creditcode) && !creditcode.equals("null")) {
				prjLnkCompVO.setSucc(creditcode);
			}
            if (StringUtils.isNotEmpty(entType) && !entType.equals("null")) {
            	prjLnkCompVO.setCompTyp(entType);
            }
            if (StringUtils.isNotEmpty(address) && !address.equals("null")) {
            	prjLnkCompVO.setRegAddr(address);
            }
            if (StringUtils.isNotEmpty(opendate) && !opendate.equals("null")) {
            	prjLnkCompVO.setRegDt(DateUtils.formatStringToDate(opendate, DateUtils.YYYY_MM_DD));
            	prjLnkCompVO.setRegDtStr(opendate);
            }
            if (StringUtils.isNotEmpty(busiscope) && !busiscope.equals("null")) {
            	prjLnkCompVO.setBizScope(busiscope);
            }
        }

        // 可支持挂靠项目类型所有集合--PRJ0148
        // 可支持挂靠项目类型默认集合
        List<SysDictionaryDTO> prjTypCdList = this.sysDictionaryApiService.searchGroup(SplSystemConstant.SPL_SYS_CD,
                SplSystemConstant.DEFAULT_ORG_CD, PrjLnkCompRelInfoConstant.SUPP_LNK_PRJ_TYP_DIC_CODE);
        if (CollectionUtils.isNotEmpty(prjTypCdList)) {
            List<KeyValueVO> allSuppLnkPrjTypCdList = new ArrayList<>(prjTypCdList.size());
            StringBuilder defaultSuppLnkPrjTypCdString = null;
            KeyValueVO keyValueVO ;
            for (SysDictionaryDTO dto : prjTypCdList) {
                keyValueVO = new KeyValueVO();
                keyValueVO.setKey(dto.getCode());
                keyValueVO.setValue(dto.getCodeNm());
                allSuppLnkPrjTypCdList.add(keyValueVO);
                if (dto.getIsSysDef() == BaseConstant.IS_YESNO_YES) {
                    if (null == defaultSuppLnkPrjTypCdString) {
                        defaultSuppLnkPrjTypCdString = new StringBuilder();
                        defaultSuppLnkPrjTypCdString.append(dto.getCode());
                    } else {
                        defaultSuppLnkPrjTypCdString.append(";").append(dto.getCode());
                    }
                }
            }
            view.addObject("suppLnkPrjTypCdListJson", JSONArray.fromObject(allSuppLnkPrjTypCdList.toArray()));
            if (null != defaultSuppLnkPrjTypCdString) {
                view.addObject("defaultSuppLnkPrjTypCdString", defaultSuppLnkPrjTypCdString.toString());
            }
        }
        List<SysDictionaryDTO> propList = this.sysDictionaryApiService.searchGroup(SplSystemConstant.FL_SYS_CD,
                SplSystemConstant.DEFAULT_ORG_CD, "SPL0061");
        List<KeyValueVO> propKvList = new ArrayList<>();
        if(CollectionUtils.isNotEmpty(propList)){
            KeyValueVO keyValueVO ;
            for (SysDictionaryDTO dictionaryDTO:propList) {
                if(StringUtils.isNotEmpty(dictionaryDTO.getCodeAttr1()) && dictionaryDTO.getCodeAttr1().equals("LNK")) {
                    keyValueVO = new KeyValueVO();
                    keyValueVO.setKey(dictionaryDTO.getCode());
                    keyValueVO.setValue(dictionaryDTO.getCodeNm());
                    propKvList.add(keyValueVO);
                }
            }
        }
        view.addObject("propCdListJson", JSONArray.fromObject(propKvList.toArray()));
        //String taskNm = request.getParameter("taskNm");
        if(StringUtils.isNotEmpty(taskNm) && "信审中心审核".equals(taskNm)){
            view.addObject("isCheckVerify", 1);
            String saveBizFlowRl = request.getParameter("saveBizFlowRl");
            view.addObject("saveBizFlowRl", saveBizFlowRl);
            String isWarnCheck = request.getParameter("isWarnCheck");
            view.addObject("isWarnCheck", isWarnCheck);
            String warnRecId = request.getParameter("warnRecId");//高风险预警记录ID
            view.addObject("warnRecId", warnRecId);
            String isRiskWarnFlow = request.getParameter("isRiskWarnFlow");//是否是挂靠公司高风险复议流程审核节点
            view.addObject("isRiskWarnFlow", isRiskWarnFlow);
        }else{
            view.addObject("isCheckVerify", 0);
        }

        view.addObject("tabNm1", LnkCompFileCfgEnum.PRJ030.getTableNm());
        view.addObject("cfgCd1", LnkCompFileCfgEnum.PRJ030.getCode());
        view.addObject("cfgOrgCd1", LnkCompFileCfgEnum.PRJ030.getOrgCd());
        view.addObject("cfgSysCd1", LnkCompFileCfgEnum.PRJ030.getSysCd());
        view.addObject("modulePath1", LnkCompFileCfgEnum.PRJ030.getModulePath());
        view.addObject("costomerPath1", LnkCompFileCfgEnum.PRJ030.getUploadCostomerPath());
        view.addObject("rootPath1", LnkCompFileCfgEnum.PRJ030.getUploadRootPath());
        view.addObject("uploadSysCd1", LnkCompFileCfgEnum.PRJ030.getUploadSysCd());
        view.addObject("tabNm2", LnkCompFileCfgEnum.PRJ029.getTableNm());
        view.addObject("cfgCd2", LnkCompFileCfgEnum.PRJ029.getCode());
        view.addObject("cfgOrgCd2", LnkCompFileCfgEnum.PRJ029.getOrgCd());
        view.addObject("cfgSysCd2", LnkCompFileCfgEnum.PRJ029.getSysCd());
        view.addObject("modulePath2", LnkCompFileCfgEnum.PRJ029.getModulePath());
        view.addObject("costomerPath2", LnkCompFileCfgEnum.PRJ029.getUploadCostomerPath());
        view.addObject("rootPath2", LnkCompFileCfgEnum.PRJ029.getUploadRootPath());
        view.addObject("uploadSysCd2", LnkCompFileCfgEnum.PRJ029.getUploadSysCd());
        view.addObject("tabNm3", LnkCompFileCfgEnum.PRJ032.getTableNm());
        view.addObject("cfgCd3", LnkCompFileCfgEnum.PRJ032.getCode());
        view.addObject("cfgOrgCd3", LnkCompFileCfgEnum.PRJ032.getOrgCd());
        view.addObject("cfgSysCd3", LnkCompFileCfgEnum.PRJ032.getSysCd());
        view.addObject("modulePath3", LnkCompFileCfgEnum.PRJ032.getModulePath());
        view.addObject("costomerPath3", LnkCompFileCfgEnum.PRJ032.getUploadCostomerPath());
        view.addObject("rootPath3", LnkCompFileCfgEnum.PRJ032.getUploadRootPath());
        view.addObject("uploadSysCd3", LnkCompFileCfgEnum.PRJ032.getUploadSysCd());

        view.addObject("propTabNm", LnkCompFileCfgEnum.PRJ034.getTableNm());
        view.addObject("propCfgCd", LnkCompFileCfgEnum.PRJ034.getCode());
        view.addObject("propCfgOrgCd", LnkCompFileCfgEnum.PRJ034.getOrgCd());
        view.addObject("propCfgSysCd", LnkCompFileCfgEnum.PRJ034.getSysCd());
        view.addObject("propModulePath", LnkCompFileCfgEnum.PRJ034.getModulePath());
        view.addObject("propCostomerPath1", LnkCompFileCfgEnum.PRJ034.getUploadCostomerPath());
        view.addObject("propRootPath", LnkCompFileCfgEnum.PRJ034.getUploadRootPath());
        view.addObject("propUploadSysCd", LnkCompFileCfgEnum.PRJ034.getUploadSysCd());

        SysUlDatCfgQueryCondition ulDatCfgQueryCondition = new SysUlDatCfgQueryCondition();
        ulDatCfgQueryCondition.setSysCd(LnkCompFileCfgEnum.PRJ029.getSysCd());//系统代码
        ulDatCfgQueryCondition.setOrgCd(LnkCompFileCfgEnum.PRJ029.getOrgCd());
        ulDatCfgQueryCondition.setIsValid(BaseConstant.IS_YESNO_YES);
        ulDatCfgQueryCondition.setIsDel(BaseConstant.IS_YESNO_NO);
        List<String> cfgCdList = new ArrayList<>();
        cfgCdList.add(LnkCompFileCfgEnum.PRJ029.getCode());//配置编号
        cfgCdList.add(LnkCompFileCfgEnum.PRJ030.getCode());
        cfgCdList.add(LnkCompFileCfgEnum.PRJ032.getCode());
        ulDatCfgQueryCondition.setCfgCdList(cfgCdList);//配置编号集合
        List<SysUlDatCfgDTO> allCfgCdList = this.uploadApiService.searchSysUlDatCfgList(ulDatCfgQueryCondition);
        if (CollectionUtils.isNotEmpty(allCfgCdList)) {
            List<SysUlDatCfgDtlDTO> allCfgDtlCdList = new ArrayList<>();
            for (SysUlDatCfgDTO dto : allCfgCdList) {
                allCfgDtlCdList.addAll(dto.getSysUlDatCfgDtlDTOList());
            }
            view.addObject("allCfgDtlCdList", JSON.toJSONString(allCfgDtlCdList));
        }

        String LinkCrAmt = request.getParameter("LinkCrAmt");
        view.addObject("LinkCrAmt", LinkCrAmt);
        view.addObject("rlPsnList", JSON.toJSONString(listPage));

        view.addObject("keyValueList", keyValueList);
        view.addObject("id", id);
        view.addObject("BuOrgCd", BuOrgCd);
        view.addObject("prjLnkComp", prjLnkCompVO);
        view.addObject("rlRsnTypList", JSON.toJSONString(prjLnkCompVO.getRlPsnList()));
        if (StringUtils.isNotEmpty(audStsCd)) {
            view.addObject("audStsCd", audStsCd);
        } else {
            view.addObject("audStsCd", prjLnkCompVO.getAudStsCd());
        }
        view.addObject("isFlow", isFlow);
        view.addObject("isLnkNmModify", isLnkNmModify);
        view.addObject("importDataSource", importDataSource);
        view.addObject("fromSrcBiz", fromSrcBiz);
        view.addObject("isOrSubmit", isOrSubmit);
        view.addObject("currentUserId", CurrentThreadContext.getCurrentUserId());
        view.addObject("isShowRate",isShowRate);
        BaseLogUtils.newWebLogger("跳转到修改挂靠公司页面").setLogOperType(LogOperEnum.REQ)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                .setWarning(false)
                .setKeys("id", id)
                .info();
        return view;
    }

    /**
     * 到添加页面
     */
    @RequestMapping(value = "/toAddPage.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView toAddPage(HttpServletRequest request, HttpServletResponse response) {
        String id = request.getParameter("id");
        String BuOrgCd = CurrentThreadContext.getCurrentBuOrgCd();
        ModelAndView view = new ModelAndView("project/prjlnkcomp/projectLnkCompAdd");
        view.addObject("id", id);
        List<KeyValueVO> keyValueList = prjLnkCompService.getOwnerCdList();
        List<KeyValueVO> prjLnkCompRlRsnTypList = prjLnkCompService.getPrjLnkCompRlRsnTypList();
        List<KeyValueVO> certTypCdList = prjLnkCompService.getCertTypCdList();
        List<PrjLnkCompRlPsnVO> list = new ArrayList<PrjLnkCompRlPsnVO>();
        String defCodNm = "";
        for (KeyValueVO keyValueVO : certTypCdList) {
            if (keyValueVO.getKey().equals(PrjLnkCompRelInfoConstant.CODE_CERT_TYP_DEF_CD)) {
                defCodNm = keyValueVO.getValue();
            }
        }
        if (CollectionUtils.isNotEmpty(prjLnkCompRlRsnTypList)) {
            for (KeyValueVO keyValueVO : prjLnkCompRlRsnTypList) {
                if (BuOrgCd.equals(PrjBscInfoConstant.CODE_BU_ORG_CD_QCJR)) {
                    if (keyValueVO.getKey().equals(PrjLnkCompRelInfoConstant.CODE_RL_TYP_CD_2) || keyValueVO.getKey().equals(PrjLnkCompRelInfoConstant.CODE_RL_TYP_CD_4)) {
                        PrjLnkCompRlPsnVO rlPsnVO = new PrjLnkCompRlPsnVO();
                        rlPsnVO.setRlTypCd(keyValueVO.getKey());
                        rlPsnVO.setRlTypCdNm(keyValueVO.getValue());
                        rlPsnVO.setCertTypCd(PrjLnkCompRelInfoConstant.CODE_CERT_TYP_DEF_CD);
                        rlPsnVO.setCertTypCdNm(defCodNm);
                        rlPsnVO.setIsSysDef(BaseConstant.IS_YESNO_YES);
                        rlPsnVO.setIsVerify(BaseConstant.IS_YESNO_YES);
                        list.add(rlPsnVO);
                    }
                } else {
                    if (!keyValueVO.getKey().equals(PrjLnkCompRelInfoConstant.CODE_RL_TYP_CD_5)) {
                        PrjLnkCompRlPsnVO rlPsnVO = new PrjLnkCompRlPsnVO();
                        rlPsnVO.setRlTypCd(keyValueVO.getKey());
                        rlPsnVO.setRlTypCdNm(keyValueVO.getValue());
                        rlPsnVO.setCertTypCd(PrjLnkCompRelInfoConstant.CODE_CERT_TYP_DEF_CD);
                        rlPsnVO.setCertTypCdNm(defCodNm);
                        rlPsnVO.setIsSysDef(BaseConstant.IS_YESNO_YES);
                        rlPsnVO.setIsVerify(BaseConstant.IS_YESNO_NO);
                        list.add(rlPsnVO);
                    }
                }


            }
        }
        ListPageVO<PrjLnkCompRlPsnVO> listPage = new ListPageVO<PrjLnkCompRlPsnVO>(list, list.size());
        view.addObject("rlPsnList", JSON.toJSONString(listPage));
        view.addObject("certTypCdList", JSON.toJSONString(certTypCdList));
        view.addObject("rlRsnTypListJSON", JSON.toJSONString(prjLnkCompRlRsnTypList));
        view.addObject("keyValueList", keyValueList);
        view.addObject("BuOrgCd", BuOrgCd);
        BaseLogUtils.newWebLogger("跳转到修改挂靠公司页面").setLogOperType(LogOperEnum.REQ)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                .setWarning(false)
                .setKeys("id", id)
                .info();
        return view;
    }


    /**
     * 到详细页面
     */
    @RequestMapping(value = "/toDetailPage.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView toDetailPage(HttpServletRequest request, HttpServletResponse response) {
        String id = request.getParameter("id");
        String isMask = request.getParameter("isMask");
        if(StringUtils.isEmpty(isMask)){
        	isMask = "0";
        }
        String BuOrgCd = "";
        //如果有流程查找流程的事业部
        SysFlowSHQueryCondition flowQc = new SysFlowSHQueryCondition();
        List<Long> idList = new ArrayList<Long>();
        idList.add(Long.valueOf(id));
        flowQc.setDataIdList(idList);
        flowQc.setWordsInTheTable(PrjLnkCompRelInfoConstant.FLOW_S_H_LNK);
        flowQc.setSysCd(CurrentThreadContext.getCurrentSysCd());
        flowQc.setStatus(BaseConstant.IS_YESNO_YES);
        List<String> busTypList = new ArrayList<String>();
        busTypList.add(FlowConstant.FLOW_MODEL_TYP_LNK);
        flowQc.setBusTypList(busTypList);
        List<SysFlowSHDTO> flowSHList = this.flowQueryApiService.searchFlowSHList(flowQc);
        if (CollectionUtils.isNotEmpty(flowSHList)) {
            for (SysFlowSHDTO sysFlowSHDTO : flowSHList) {
                if (Long.valueOf(id).equals(sysFlowSHDTO.getDataId())) {
                    BuOrgCd = sysFlowSHDTO.getBuOrgCd();
                    break;
                }
            }
        } else {
            BuOrgCd = CurrentThreadContext.getCurrentBuOrgCd();
        }

        ModelAndView view = new ModelAndView("project/prjlnkcomp/projectLnkCompDetail");
        view.addObject("id", id);
        view.addObject("isMask", isMask);
        BaseLogUtils.newWebLogger("跳转到挂靠公司详细页面").setLogOperType(LogOperEnum.REQ)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                .setWarning(false)
                .setKeys("id", id)
                .info();
        PrjLnkCompVO vo = this.prjLnkCompService.selectById(Long.valueOf(id));
        String ownerCd = vo.getOwnerCd();
        //附件资料配置

        if (StringUtils.isNotEmpty(ownerCd)) {
            if ("1".equals(ownerCd)) {
                view.addObject("tabNm", LnkCompFileCfgEnum.PRJ030.getTableNm());
                view.addObject("cfgCd", LnkCompFileCfgEnum.PRJ030.getCode());
                view.addObject("cfgOrgCd", LnkCompFileCfgEnum.PRJ030.getOrgCd());
                view.addObject("cfgSysCd", LnkCompFileCfgEnum.PRJ030.getSysCd());
                view.addObject("modulePath", LnkCompFileCfgEnum.PRJ030.getModulePath());
                view.addObject("costomerPath", LnkCompFileCfgEnum.PRJ030.getUploadCostomerPath());
                view.addObject("rootPath", LnkCompFileCfgEnum.PRJ030.getUploadRootPath());
                view.addObject("uploadSysCd", LnkCompFileCfgEnum.PRJ030.getUploadSysCd());
            } else if ("2".equals(ownerCd)) {
                view.addObject("tabNm", LnkCompFileCfgEnum.PRJ029.getTableNm());
                view.addObject("cfgCd", LnkCompFileCfgEnum.PRJ029.getCode());
                view.addObject("cfgOrgCd", LnkCompFileCfgEnum.PRJ029.getOrgCd());
                view.addObject("cfgSysCd", LnkCompFileCfgEnum.PRJ029.getSysCd());
                view.addObject("modulePath", LnkCompFileCfgEnum.PRJ029.getModulePath());
                view.addObject("costomerPath", LnkCompFileCfgEnum.PRJ029.getUploadCostomerPath());
                view.addObject("rootPath", LnkCompFileCfgEnum.PRJ029.getUploadRootPath());
                view.addObject("uploadSysCd", LnkCompFileCfgEnum.PRJ029.getUploadSysCd());
            } else {
                view.addObject("tabNm", LnkCompFileCfgEnum.PRJ032.getTableNm());
                view.addObject("cfgCd", LnkCompFileCfgEnum.PRJ032.getCode());
                view.addObject("cfgOrgCd", LnkCompFileCfgEnum.PRJ032.getOrgCd());
                view.addObject("cfgSysCd", LnkCompFileCfgEnum.PRJ032.getSysCd());
                view.addObject("modulePath", LnkCompFileCfgEnum.PRJ032.getModulePath());
                view.addObject("costomerPath", LnkCompFileCfgEnum.PRJ032.getUploadCostomerPath());
                view.addObject("rootPath", LnkCompFileCfgEnum.PRJ032.getUploadRootPath());
                view.addObject("uploadSysCd", LnkCompFileCfgEnum.PRJ032.getUploadSysCd());
            }
        } else {
            view.addObject("tabNm", LnkCompFileCfgEnum.PRJ029.getTableNm());
            view.addObject("cfgCd", LnkCompFileCfgEnum.PRJ029.getCode());
            view.addObject("cfgOrgCd", LnkCompFileCfgEnum.PRJ029.getOrgCd());
            view.addObject("cfgSysCd", LnkCompFileCfgEnum.PRJ029.getSysCd());
            view.addObject("modulePath", LnkCompFileCfgEnum.PRJ029.getModulePath());
            view.addObject("costomerPath", LnkCompFileCfgEnum.PRJ029.getUploadCostomerPath());
            view.addObject("rootPath", LnkCompFileCfgEnum.PRJ029.getUploadRootPath());
            view.addObject("uploadSysCd", LnkCompFileCfgEnum.PRJ029.getUploadSysCd());
        }

        //17-8-9 by YAOXIURONG 挂靠公司审核流程传递标识维护挂靠公司流程权限
        String saveBizFlowRl = request.getParameter("saveBizFlowRl");
        String taskNm = request.getParameter("taskNm");
        if(StringUtils.isNotEmpty(taskNm) && taskNm.equals("信审中心审核")){
        	view.addObject("isCheck",1);
        	view.addObject("isCheckVerify", 1);
        }else{
        	view.addObject("isCheck",0);
        	view.addObject("isCheckVerify", 0);
        }
        view.addObject("saveBizFlowRl", saveBizFlowRl);
        view.addObject("buOrgCd", BuOrgCd);

        String isWarnCheck = request.getParameter("isWarnCheck");
        view.addObject("isWarnCheck", isWarnCheck);
        String warnRecId = request.getParameter("warnRecId");//高风险预警记录ID
        view.addObject("warnRecId", warnRecId);
        String isRiskWarnFlow = request.getParameter("isRiskWarnFlow");//是否是挂靠公司高风险复议流程审核节点
        view.addObject("isRiskWarnFlow", isRiskWarnFlow);
        
        view.addObject("currentUserId", CurrentThreadContext.getCurrentUserId());
        return view;
    }

    /**
     * 初始化列表
     */
    @SuppressWarnings("unchecked")
    @RequestMapping(value = "/initList.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object initList(HttpServletRequest request, HttpServletResponse response) {
        BaseLogUtils.info(logger,"initList","挂靠公司初始化列表请求参数：" + this.getRequestParameter(request));
        String currentPage = request.getParameter("page");
        String pageSize = request.getParameter("pagesize");
        String lnkCompNm = request.getParameter("lnkCompNm");
        String audStsCd = request.getParameter("audStsCd");
        String orgCd = request.getParameter("orgCd");
        String sortName = request.getParameter("sortname");
        String sortOrder = request.getParameter("sortorder");
        String nonAudStsCd = request.getParameter("nonAudStsCd");
        String audStsCdStr = request.getParameter("audStsCdList");
        //20180816 yaoxr ------------------- 开始
        String lnkCompIdsString = request.getParameter("lnkCompIdsString");
        String condition = request.getParameter("condition");
        String prjId = request.getParameter("prjId");//项目ID
        String vehNo = request.getParameter("vehNo");
        String prjTypCd = request.getParameter("prjTypCd");
        String splid = request.getParameter("splId");
        Long splId = StringUtils.isNotEmpty(splid)? Long.valueOf(splid) : null;
		String value = "";
		if(PrjBscInfoConstant.PRJ_TYP_CD_CDDYWUL.equals(prjTypCd) || PrjBscInfoConstant.PRJ_TYP_CD_ESCJYD.equals(prjTypCd)|| PrjBscInfoConstant.PRJ_TYP_CD_OWNJYD.equals(prjTypCd)){
            if(StringUtils.isEmpty(prjId)){
                throw new BaseException("项目ID不能为空");
            }
            if(PrjBscInfoConstant.PRJ_TYP_CD_CDDYWUL.equals(prjTypCd)){
                if(StringUtils.isEmpty(vehNo)){
                    throw new BaseException("车牌号不能为空");
                }
            }
        }
		if(StringUtils.isNotBlank(condition)){
			String con = condition.substring(1, condition.length()-1);
			if(StringUtils.isNotBlank(con)){
				net.sf.json.JSONObject fromObject = net.sf.json.JSONObject.fromObject(con);
				value = (String) fromObject.get("value");
			}
		}
		//20180816 yaoxr ------------------- 结束
        
        /****caolei 2018-9-10*****/
        String isQueryExpDt = request.getParameter("isQueryExpDt");
        String rlNm = request.getParameter("rlNm");
        String certNo = request.getParameter("certNo");
        String rlTel = request.getParameter("rlTel");
        Pager page = new Pager();
        if (StringUtils.isNotEmpty(currentPage)) {
            page.setCurrentPage(Integer.parseInt(currentPage));
        }

        if (StringUtils.isNotEmpty(pageSize)) {
            page.setEveryPage(Integer.parseInt(pageSize));
        }

        PrjLnkCompQueryCondition qc = new PrjLnkCompQueryCondition();
        if (StringUtils.isNotEmpty(lnkCompNm)) {
            qc.setLnkCompNm(lnkCompNm);
        }

        //20180816 yaoxr ------------------- 开始
        if (StringUtils.isNotEmpty(value)) {
			qc.setLnkCompNm(value.trim());
		}else if(StringUtils.isNotEmpty(lnkCompIdsString)){
			String[] strings = lnkCompIdsString.trim().split(";");
			List<Long> lnkCompIds = new ArrayList<Long>();
			for (String string : strings) {
				lnkCompIds.add(Long.valueOf(string));
			}
			qc.setIdList(lnkCompIds);
		}
        //20180816 yaoxr ------------------- 结束
        String isBlackList = request.getParameter("isBlackList");//是否加入黑名单
        if(StringUtils.isNotBlank(isBlackList)){
            qc.setIsBlackList(Integer.valueOf(isBlackList));
        }
        /**caolei 2018-9-10**/
        String isQuery = "0";
        if(StringUtils.isNotEmpty(rlNm)){
        	qc.setRlNm(rlNm);
        	isQuery = "1";
        }
        if(StringUtils.isNotEmpty(certNo)){
        	qc.setCertNo(certNo);
        	isQuery = "1";
        }
        if(StringUtils.isNotEmpty(rlTel)){
        	qc.setRlTel(rlTel);
        	isQuery = "1" ;
        }
        
        qc.setIsQuery(isQuery);
        if(StringUtils.isNotEmpty(isQueryExpDt) && "1".equals(isQueryExpDt)){
        	String expDt = DateUtils.formatDateToString(new Date(), DateUtils.YYYY_MM_DD);
        	qc.setExpDt(expDt);
        }
        if (StringUtils.isNotBlank(nonAudStsCd)) {
            qc.setNonAudStsCd(nonAudStsCd);
        }
        if (StringUtils.isNotBlank(audStsCd)) {
           /* List<String> audStsCdList = new ArrayList<String>();
            audStsCdList.add(audStsCd);
            qc.setAudStsCdList(audStsCdList);*/
            qc.setAudStsCd(audStsCd);
        }
        if (StringUtils.isNotBlank(orgCd)) {
            qc.setOrgCode(orgCd);
        }
        if (StringUtils.isNotBlank(sortName) && StringUtils.isNotBlank(sortOrder)) {
            qc.setSortName(sortName);
            qc.setSortOrder(sortOrder);
        }
        if (StringUtils.isNotBlank(audStsCdStr)) {
            List<String> audStsCdList = new ArrayList<String>();
            JSONArray audStsArray = JSONArray.fromObject(audStsCdStr);
            for (Object object : audStsArray) {
                audStsCdList.add(object.toString());
            }
            qc.setAudStsCdList(audStsCdList);
        }
        qc.setIsDel(BaseConstant.IS_YESNO_NO);

       /* if (!(CurrentThreadContext.getCurrentBuOrgCd().equals("0000") || CurrentThreadContext.getCurrentBuOrgCd().equals("00001005"))) {
            qc.setBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
        }*/

        if (!(CurrentThreadContext.getCurrentBuOrgCd().equals(PrjBscInfoConstant.CODE_BU_ORG_CD_QCJR))) {
            qc.setDefBuOrgCd(PrjBscInfoConstant.CODE_PRJ_FILE_DEF_ORG);
        }else{
            qc.setDefBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
        }

        String currentBuOrgCd = CurrentThreadContext.getCurrentBuOrgCd();
		Map<String, String> buOrgCdMap = this.sysDictionaryApiService.searchGroupToMap(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), DictionaryConstant.CODE_SYS_BU_ORG_CD);
		if(buOrgCdMap.containsKey(currentBuOrgCd)){
			qc.setBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
		}
        
        qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
        qc.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
        page.setCondition(qc);
        Pager pager = this.prjLnkCompService.searchListPage(page);
        List<PrjLnkCompVO> list = (List<PrjLnkCompVO>) pager.getResultList();
        List<PrjLnkCompVO> resList = new ArrayList<PrjLnkCompVO>();
        /**
         * 绑定征信的挂靠公司数据
         */
        if(PrjBscInfoConstant.PRJ_TYP_CD_CDDYWUL.equals(prjTypCd) || PrjBscInfoConstant.PRJ_TYP_CD_ESCJYD.equals(prjTypCd) || PrjBscInfoConstant.PRJ_TYP_CD_OWNJYD.equals(prjTypCd)){
            DataResultDTO resultDTO = this.prjLnkCompService.selectRiskLnkList(Long.valueOf(prjId), vehNo, splId);
            Map<Long,String> lnkIds = new HashMap<Long,String>();
            if(resultDTO != null && resultDTO.getData() != null){
                List<RcCstChannelInfoDTO> rcCstChannelInfoDTOS = (List<RcCstChannelInfoDTO>)(resultDTO.getData());
                if(CollectionUtils.isNotEmpty(rcCstChannelInfoDTOS)){
                    List<SysDictionaryDTO> lnkStartLvlList = this.sysDictionaryApiService.searchGroup(WebBaseConstant.SPL_SYS_CD, CurrentThreadContext.getCurrentOrgCd(), PrjPrdDtlConstant.CODE_GRP_CD_START_LVL);
                    for (RcCstChannelInfoDTO rcCstChannelInfoDTO : rcCstChannelInfoDTOS) {
                        Long splStarLevel = rcCstChannelInfoDTO.getSplStarLevel();
                        String starLevelNm = "";
                        if(rcCstChannelInfoDTO.getChannelId() != null){
                            if(splStarLevel != null){
                                for (SysDictionaryDTO sysDictionaryDTO : lnkStartLvlList) {
                                    String code = sysDictionaryDTO.getCode();
                                    if (splStarLevel.equals(Long.valueOf(code))) {
                                        starLevelNm = sysDictionaryDTO.getCodeNm();
                                    }
                                }
                            }
                            if(!lnkIds.containsKey(rcCstChannelInfoDTO.getChannelId())){
                                lnkIds.put(rcCstChannelInfoDTO.getChannelId(),starLevelNm);
                            }
                        }
                    }
                }
            }
            if(MapUtils.isNotEmpty(lnkIds)){
                qc.setIdList(new ArrayList<>(lnkIds.keySet()));
                page.setCondition(qc);
                Pager pageOld = this.prjLnkCompService.searchListPage(page);
                resList = (List<PrjLnkCompVO>) pageOld.getResultList();
                if(CollectionUtils.isNotEmpty(resList)){
                    for (PrjLnkCompVO prjLnkCompVO : resList) {
                        if(lnkIds.containsKey(prjLnkCompVO.getId())){
                            prjLnkCompVO.setStarLevelNm(lnkIds.get(prjLnkCompVO.getId()));
                        }
                    }
                }
            }
        }else{
            resList = list;
        }
        //2018-8-23 08:58:48 add
        if(CollectionUtils.isNotEmpty(resList)){
            //获取企业归属CODE-归属名称 MAP
            Map<String, String> ownerCdAndNmMap = this.sysDictionaryApiService.searchGroupToMap(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), fl.spl.facade.framework.constant.DictionaryConstant.SYS_LNK_OWNER_CODE_DIC_CD);

            List<Long> ids = new ArrayList<>(resList.size());

            for (PrjLnkCompVO prjLnkCompVO : resList) {
                Date expDt = prjLnkCompVO.getExpDt();
                long l = DateUtils.getDaysBetweenTwoDates(new Date(), expDt);
                if(l>15){
                    prjLnkCompVO.setIsValid(0);
                }else if(0<l && l<15){
                    prjLnkCompVO.setIsValid(1);
                }else{
                    prjLnkCompVO.setIsValid(2);
                }
                if(CollectionUtils.isMapNotEmpty(ownerCdAndNmMap) && ownerCdAndNmMap.containsKey(prjLnkCompVO.getOwnerCd())){
                    prjLnkCompVO.setOwnerCdNm(ownerCdAndNmMap.get(prjLnkCompVO.getOwnerCd()));
                }
                ids.add(prjLnkCompVO.getId());
            }
            ownerCdAndNmMap = null ;

            //初始化供应商星级信息
            Map<String, String> starLevelMap = sysDictionaryApiService.searchGroupToMap(SplSystemConstant.SPL_SYS_CD, SplSystemConstant.DEFAULT_ORG_CD, SplRateRelInfoConstant.SPL_RATE_STAR_DIC_CD);
            StringBuilder rpcSign = new StringBuilder();
            rpcSign.append(System.currentTimeMillis()).append("_").append(CurrentThreadContext.getCurrentUserName()).append("_").append(CurrentThreadContext.getCurrentUserId());
            SplRateRelInfoQC splRateRelInfoQC = new SplRateRelInfoQC();
            splRateRelInfoQC.setDataIdList(ids);
            splRateRelInfoQC.setTabNm("PRJ_LNK_COMP");
            splRateRelInfoQC.setIsNew(BaseConstant.IS_YESNO_YES);
            splRateRelInfoQC.setIsDel(BaseConstant.IS_YESNO_NO);
            splRateRelInfoQC.setIsValid(BaseConstant.IS_YESNO_YES);
            DataResultDTO resultDTO = this.splRateRelInfoQueryApiService.searchSplRateRelInfoDTOList(splRateRelInfoQC,SplSystemConstant.FL_WEB_CHL_CD, null,rpcSign.toString());
            BaseLogUtils.newWebLogger("查询挂靠公司星级信息.DATA:"+ JSONObject.toJSONString(resultDTO)).setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();
            if(BaseConstant.IS_YESNO_YES == resultDTO.getSuccess()){
                List<SplRateRelInfoDTO> splRateInfoList = (List<SplRateRelInfoDTO>)resultDTO.getData() ;
                if(CollectionUtils.isNotEmpty(splRateInfoList)){
                    Map<Long,Long> splIdByStarLevelMap = new HashMap<>();
                    for (SplRateRelInfoDTO rateRelDTO:splRateInfoList) {
                        splIdByStarLevelMap.put(rateRelDTO.getDataId(),rateRelDTO.getStarLevel());
                    }
                    for (PrjLnkCompVO vo:resList) {
                        Long levelCd = splIdByStarLevelMap.get(vo.getId());
                        if(StringUtils.isNotEmpty(levelCd)) {
                            vo.setStarLevelNm(starLevelMap.get(levelCd.toString()));
                        }
                    }
                }
            }
        }
        ListPageVO<PrjLnkCompVO> listPage = new ListPageVO<PrjLnkCompVO>(resList, pager.getTotalCount());
        BaseLogUtils.newWebLogger("获取挂靠公司数据完成").setLogOperType(LogOperEnum.RESP)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                .setWarning(false)
                .setKeys("listPage", JSON.toJSONString(listPage))
                .info();
        return listPage;
    }

    /**
     * 初始化列表
     */
    @RequestMapping(value = "/initPreList.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object initPreList(HttpServletRequest request, HttpServletResponse response) {
        String prjId = request.getParameter("prjId");//项目ID
        BaseLogUtils.newLogger("查询预审页需挂靠的关联公司列表，prjId:{},request:{}",prjId,JSON.toJSONString(request.getParameterMap())).info();
        String currentPage = request.getParameter("page");
        String pageSize = request.getParameter("pagesize");
        String lnkCompNm = request.getParameter("lnkCompNm");
        String orgCd = request.getParameter("orgCd");
        String sortName = request.getParameter("sortname");
        String sortOrder = request.getParameter("sortorder");
        String audStsCdStr = request.getParameter("audStsCdList");
        String vehNo = request.getParameter("vehNo");
        String prjTypCd = request.getParameter("prjTypCd");
        String isQueryExpDt = request.getParameter("isQueryExpDt");
        String rlNm = request.getParameter("rlNm");
        String certNo = request.getParameter("certNo");
        String rlTel = request.getParameter("rlTel");
        String isBlackList = request.getParameter("isBlackList");//是否加入黑名单
        Long splId = StringUtils.isNotEmpty(request.getParameter("splId"))? Long.valueOf(request.getParameter("splId")) : null;

        if(PrjBscInfoConstant.PRJ_TYP_CD_CDDYWUL.equals(prjTypCd) || PrjBscInfoConstant.PRJ_TYP_CD_ESCJYD.equals(prjTypCd)|| PrjBscInfoConstant.PRJ_TYP_CD_OWNJYD.equals(prjTypCd)){
            if(StringUtils.isEmpty(prjId)){
                throw new BaseException("项目ID不能为空");
            }
            if(PrjBscInfoConstant.PRJ_TYP_CD_CDDYWUL.equals(prjTypCd)){
                if(StringUtils.isEmpty(vehNo)){
                    throw new BaseException("车牌号不能为空");
                }
            }
        }

        PrjBscInfoVO vo = prjBscInfoService.selectById(Long.valueOf(prjId));
        BaseLogUtils.newLogger("查询项目信息，prjId:{},vo:{}",prjId,JSON.toJSONString(vo)).info();

        Pager page = new Pager();
        if (StringUtils.isNotEmpty(currentPage)) {
            page.setCurrentPage(Integer.parseInt(currentPage));
        }
        if (StringUtils.isNotEmpty(pageSize)) {
            page.setEveryPage(Integer.parseInt(pageSize));
        }
        PrjLnkCompQueryCondition qc = new PrjLnkCompQueryCondition();
        if (StringUtils.isNotEmpty(lnkCompNm)) {
            qc.setLnkCompNm(lnkCompNm);
        }
        if(StringUtils.isNotBlank(isBlackList)){
            qc.setIsBlackList(Integer.valueOf(isBlackList));
        }
        String isQuery = "0";
        if(StringUtils.isNotEmpty(rlNm)){
            qc.setRlNm(rlNm);
            isQuery = "1";
        }
        if(StringUtils.isNotEmpty(certNo)){
            qc.setCertNo(certNo);
            isQuery = "1";
        }
        if(StringUtils.isNotEmpty(rlTel)){
            qc.setRlTel(rlTel);
            isQuery = "1" ;
        }

        qc.setIsQuery(isQuery);
        if(StringUtils.isNotEmpty(isQueryExpDt) && "1".equals(isQueryExpDt)){
            String expDt = DateUtils.formatDateToString(new Date(), DateUtils.YYYY_MM_DD);
            qc.setExpDt(expDt);
        }
        if (StringUtils.isNotBlank(orgCd)) {
            qc.setOrgCode(orgCd);
        }
        if (StringUtils.isNotBlank(sortName) && StringUtils.isNotBlank(sortOrder)) {
            qc.setSortName(sortName);
            qc.setSortOrder(sortOrder);
        }
        if (StringUtils.isNotBlank(audStsCdStr)) {
            List<String> audStsCdList = new ArrayList<String>();
            JSONArray audStsArray = JSONArray.fromObject(audStsCdStr);
            for (Object object : audStsArray) {
                audStsCdList.add(object.toString());
            }
            qc.setAudStsCdList(audStsCdList);
        }
        qc.setIsDel(BaseConstant.IS_YESNO_NO);
        qc.setBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
        qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
        qc.setOrgCd(CurrentThreadContext.getCurrentOrgCd());

        List<PrjLnkCompVO> resList = new ArrayList<PrjLnkCompVO>();

        DataResultDTO resultDTO = this.prjLnkCompService.selectRiskLnkList(Long.valueOf(prjId), vehNo, splId);
        BaseLogUtils.newLogger("查询客户征信绑定挂靠数据，prjId:{},resultDTO:{}",prjId,JSON.toJSONString(resultDTO)).info();
        Map<Long,String> lnkIds = new HashMap<Long,String>();//渠道id--星级
        Map<Long,Long> lnkIdRcCstIds = new HashMap<>();//渠道id--前置征信id
        if(resultDTO != null && resultDTO.getData() != null){
            List<RcCstChannelInfoDTO> rcCstChannelInfoDTOS = (List<RcCstChannelInfoDTO>)(resultDTO.getData());
            if(CollectionUtils.isNotEmpty(rcCstChannelInfoDTOS)){
                List<SysDictionaryDTO> lnkStartLvlList = this.sysDictionaryApiService.searchGroup(WebBaseConstant.SPL_SYS_CD, CurrentThreadContext.getCurrentOrgCd(), PrjPrdDtlConstant.CODE_GRP_CD_START_LVL);
                for (RcCstChannelInfoDTO rcCstChannelInfoDTO : rcCstChannelInfoDTOS) {
                    if (null != rcCstChannelInfoDTO.getChannelId()){
                        if (null != rcCstChannelInfoDTO.getSplStarLevel()){
                            Long splStarLevel = rcCstChannelInfoDTO.getSplStarLevel();
                            String starLevelNm = "";
                            for (SysDictionaryDTO sysDictionaryDTO : lnkStartLvlList) {
                                String code = sysDictionaryDTO.getCode();
                                if (splStarLevel.equals(Long.valueOf(code))) {
                                    starLevelNm = sysDictionaryDTO.getCodeNm();
                                }
                            }
                            if(!lnkIds.containsKey(rcCstChannelInfoDTO.getChannelId())){
                                lnkIds.put(rcCstChannelInfoDTO.getChannelId(),starLevelNm);
                            }
                        }
                        if (null != rcCstChannelInfoDTO.getRcCstBscInfoId()){
                            if(!lnkIdRcCstIds.containsKey(rcCstChannelInfoDTO.getChannelId())){
                                lnkIdRcCstIds.put(rcCstChannelInfoDTO.getChannelId(),rcCstChannelInfoDTO.getRcCstBscInfoId());
                            }
                        } else {
                            CstBscInfoVO cstBscInfoVO = cstBscInfoService.selectDetailById(vo.getCstId());
                            BaseLogUtils.newLogger("查询客户经理数据，prjId:{},lnkIds:{}",prjId,JSON.toJSONString(lnkIds)).info();
                            String mp = "";
                            String cstNm = "";
                            String certNp = "";
                            if (null != cstBscInfoVO){
                                if (CustomerConstant.CST_TYP_CD_NP.equals(cstBscInfoVO.getCstTypCd()) && null != cstBscInfoVO.getCstNpBscInfoVO()){
                                    mp = cstBscInfoVO.getCstNpBscInfoVO().getMp1();
                                    cstNm = cstBscInfoVO.getCstNm();
                                    certNo = cstBscInfoVO.getCertNo();
                                }
                                if (CustomerConstant.CST_TYP_CD_CORP.equals(cstBscInfoVO.getCstTypCd())){
                                    CstCorpTeamQueryCondition condition = new CstCorpTeamQueryCondition();
                                    condition.setCstId(vo.getCstId());
                                    condition.setIsDel(BaseConstant.IS_YESNO_NO);
                                    condition.setmTypCd(CustomerConstant.CST_CORP_TEAM_LOWER);
                                    List<CstCorpTeamDTO> cstCorpTeamDTOList = this.customerApiService.searchCstCorpTeamList(condition);
                                    BaseLogUtils.newLogger("根据客户经理查询承租人征信.法人团队信息：" + JSON.toJSONString(cstCorpTeamDTOList)).info();
                                    if(CollectionUtils.isNotEmpty(cstCorpTeamDTOList)){
                                        for(CstCorpTeamDTO cstCorpTeamDTO : cstCorpTeamDTOList){
                                            if(StringUtils.isNotBlank(cstCorpTeamDTO.getCertNo())){
                                                certNo = cstCorpTeamDTO.getCertNo();
                                                cstNm = cstCorpTeamDTO.getMNm();
                                                mp = cstCorpTeamDTO.getMp1();
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                            DataResultDTO dataResultDTO = rskCtrlService.searchRcCstBscInfoByCstMgr(certNo, cstNm, mp, vo.getCstMgrId());
                            BaseLogUtils.newLogger("根据客户经理查询承租人征信，prjId:{},dataResultDTO:{}",prjId,JSON.toJSONString(dataResultDTO)).info();
                            if(null != dataResultDTO&& BaseConstant.IS_YESNO_YES == dataResultDTO.getSuccess()){
                                TheWorstRcCstBscInfoResult rcCstCddunderlineBody = (TheWorstRcCstBscInfoResult)(dataResultDTO.getData());
                                if(null != rcCstCddunderlineBody && !lnkIdRcCstIds.containsKey(rcCstChannelInfoDTO.getChannelId())){
                                    lnkIdRcCstIds.put(rcCstChannelInfoDTO.getChannelId(),rcCstCddunderlineBody.getRcCstBscInfoId());
                                }
                            }
                        }
                    }
                }
            }
        }
        BaseLogUtils.newLogger("渠道id--星级数据，prjId:{},lnkIds:{}",prjId,JSON.toJSONString(lnkIds)).info();
        BaseLogUtils.newLogger("渠道id--前置征信id，prjId:{},lnkIdRcCstIds:{}",prjId,JSON.toJSONString(lnkIdRcCstIds)).info();
        if(MapUtils.isNotEmpty(lnkIds)){
            qc.setIdList(new ArrayList<>(lnkIds.keySet()));
            page.setCondition(qc);
            BaseLogUtils.newLogger("查询符合的挂靠数据，prjId:{},qc:{}",prjId,JSON.toJSONString(qc)).info();
            Pager pageOld = this.prjLnkCompService.searchListPage(page);
            BaseLogUtils.newLogger("查询符合的挂靠数据，prjId:{},pageOld:{}",prjId,JSON.toJSONString(pageOld)).info();
            resList = (List<PrjLnkCompVO>) pageOld.getResultList();
            if(CollectionUtils.isNotEmpty(resList)){
                for (PrjLnkCompVO prjLnkCompVO : resList) {
                    if(lnkIds.containsKey(prjLnkCompVO.getId())){
                        prjLnkCompVO.setStarLevelNm(lnkIds.get(prjLnkCompVO.getId()));
                    }
                    if(lnkIdRcCstIds.containsKey(prjLnkCompVO.getId())){
                        prjLnkCompVO.setRcCstBscInfoId(lnkIdRcCstIds.get(prjLnkCompVO.getId()));
                    }
                }
            }
        }
        BaseLogUtils.newLogger("查询挂靠数据，prjId:{},resList:{}",prjId,JSON.toJSONString(resList)).info();
        if (CollectionUtils.isNotEmpty(resList)){
            ListPageVO<PrjLnkCompVO> listPage = new ListPageVO<PrjLnkCompVO>(resList, resList.size());
            return listPage;
        }
        return new ListPageVO<PrjLnkCompVO>();
    }

    /**
     * 初始化列表
     */
    @SuppressWarnings("unchecked")
    @RequestMapping(value = "/initListNew.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object initListNew(HttpServletRequest request, HttpServletResponse response) {
        String currentPage = request.getParameter("page");
        String pageSize = request.getParameter("pagesize");
        String lnkCompNm = request.getParameter("lnkCompNm");
        String audStsCd = request.getParameter("audStsCd");
        String orgCd = request.getParameter("orgCd");
        String sortName = request.getParameter("sortname");
        String sortOrder = request.getParameter("sortorder");
        String nonAudStsCd = request.getParameter("nonAudStsCd");
        String audStsCdStr = request.getParameter("audStsCdList");
        //20180816 yaoxr ------------------- 开始
        String lnkCompIdsString = request.getParameter("lnkCompIdsString");
        String prjId = request.getParameter("prjId");//项目ID
        String vehNo = request.getParameter("vehNo");
        String prjTypCd = request.getParameter("prjTypCd");
        String splIds = request.getParameter("splId");
        Long splId = StringUtils.isNotEmpty(splIds)? Long.valueOf(splIds) : null;
        String value = "";

        /****caolei 2018-9-10*****/
        String isQueryExpDt = request.getParameter("isQueryExpDt");
        String rlNm = request.getParameter("rlNm");
        String certNo = request.getParameter("certNo");
        String rlTel = request.getParameter("rlTel");

        String guarCd = request.getParameter("guarCd");
        String compEffectIsValid = request.getParameter("compEffectIsValid");

        Pager page = new Pager();
        if (StringUtils.isNotEmpty(currentPage)) {
            page.setCurrentPage(Integer.parseInt(currentPage));
        }

        if (StringUtils.isNotEmpty(pageSize)) {
            page.setEveryPage(Integer.parseInt(pageSize));
        }

        PrjLnkCompQueryCondition qc = new PrjLnkCompQueryCondition();
        if (StringUtils.isNotEmpty(lnkCompNm)) {
            qc.setLnkCompNm(lnkCompNm);
        }

        //20180816 yaoxr ------------------- 结束
        String isBlackList = request.getParameter("isBlackList");//是否加入黑名单
        if(StringUtils.isNotBlank(isBlackList)){
            qc.setIsBlackList(Integer.valueOf(isBlackList));
        }
        /**caolei 2018-9-10**/
        String isQuery = "0";
        if(StringUtils.isNotEmpty(rlNm)){
            qc.setRlNm(rlNm);
            isQuery = "1";
        }
        if(StringUtils.isNotEmpty(certNo)){
            qc.setCertNo(certNo);
            isQuery = "1";
        }
        if(StringUtils.isNotEmpty(rlTel)){
            qc.setRlTel(rlTel);
            isQuery = "1" ;
        }

        qc.setIsQuery(isQuery);
        if(StringUtils.isNotEmpty(isQueryExpDt) && "1".equals(isQueryExpDt)){
            String expDt = DateUtils.formatDateToString(new Date(), DateUtils.YYYY_MM_DD);
            qc.setExpDt(expDt);
        }
        if (StringUtils.isNotBlank(nonAudStsCd)) {
            qc.setNonAudStsCd(nonAudStsCd);
        }
        if (StringUtils.isNotBlank(audStsCd)) {
           /* List<String> audStsCdList = new ArrayList<String>();
            audStsCdList.add(audStsCd);
            qc.setAudStsCdList(audStsCdList);*/
            qc.setAudStsCd(audStsCd);
        }
        if (StringUtils.isNotBlank(orgCd)) {
            qc.setOrgCode(orgCd);
        }
        if (StringUtils.isNotBlank(sortName) && StringUtils.isNotBlank(sortOrder)) {
            qc.setSortName(sortName);
            qc.setSortOrder(sortOrder);
        }
        if (StringUtils.isNotBlank(audStsCdStr)) {
            List<String> audStsCdList = new ArrayList<String>();
            JSONArray audStsArray = JSONArray.fromObject(audStsCdStr);
            for (Object object : audStsArray) {
                audStsCdList.add(object.toString());
            }
            qc.setAudStsCdList(audStsCdList);
        }
        if(StringUtils.isNotEmpty(guarCd)){
            qc.setGuarCd(guarCd);
        }
        if(StringUtils.isNotEmpty(compEffectIsValid)){
            qc.setCompEffectIsValid(Integer.valueOf(compEffectIsValid));
        }
        qc.setIsDel(BaseConstant.IS_YESNO_NO);

       /* if (!(CurrentThreadContext.getCurrentBuOrgCd().equals("0000") || CurrentThreadContext.getCurrentBuOrgCd().equals("00001005"))) {
            qc.setBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
        }*/

        if (!(CurrentThreadContext.getCurrentBuOrgCd().equals(PrjBscInfoConstant.CODE_BU_ORG_CD_QCJR))) {
            qc.setDefBuOrgCd(PrjBscInfoConstant.CODE_PRJ_FILE_DEF_ORG);
        }else{
            qc.setDefBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
        }

        String currentBuOrgCd = CurrentThreadContext.getCurrentBuOrgCd();
        Map<String, String> buOrgCdMap = this.sysDictionaryApiService.searchGroupToMap(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), DictionaryConstant.CODE_SYS_BU_ORG_CD);
        if(buOrgCdMap.containsKey(currentBuOrgCd)){
            qc.setBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
        }

        qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
        qc.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
        page.setCondition(qc);
        Pager pager = this.prjLnkCompService.searchListPage(page);
        List<PrjLnkCompVO> list = (List<PrjLnkCompVO>) pager.getResultList();
        List<PrjLnkCompVO> resList = new ArrayList<PrjLnkCompVO>();
        /**
         * 绑定征信的挂靠公司数据
         */
        DataResultDTO result = this.prjLnkCompService.selectRiskLnkList(Long.valueOf(prjId), vehNo, splId);
        Map<Long,String> lnkIds = new HashMap<Long,String>();
        List<RcCstChannelInfoDTO> rcCstChannelInfoDTOS = new ArrayList<>();
        if(result != null && result.getData() != null){
            rcCstChannelInfoDTOS = (List<RcCstChannelInfoDTO>)(result.getData());
            if(CollectionUtils.isNotEmpty(rcCstChannelInfoDTOS)){
                List<SysDictionaryDTO> lnkStartLvlList = this.sysDictionaryApiService.searchGroup(WebBaseConstant.SPL_SYS_CD, CurrentThreadContext.getCurrentOrgCd(), PrjPrdDtlConstant.CODE_GRP_CD_START_LVL);
                for (RcCstChannelInfoDTO rcCstChannelInfoDTO : rcCstChannelInfoDTOS) {
                    Long splStarLevel = rcCstChannelInfoDTO.getSplStarLevel();
                    String starLevelNm = "";
                    if(rcCstChannelInfoDTO.getChannelId() != null){
                        if(splStarLevel != null){
                            for (SysDictionaryDTO sysDictionaryDTO : lnkStartLvlList) {
                                String code = sysDictionaryDTO.getCode();
                                if (splStarLevel.equals(Long.valueOf(code))) {
                                    starLevelNm = sysDictionaryDTO.getCodeNm();
                                }
                            }
                        }
                        if(!lnkIds.containsKey(rcCstChannelInfoDTO.getChannelId())){
                            lnkIds.put(rcCstChannelInfoDTO.getChannelId(),starLevelNm);
                        }
                    }
                }
            }
        }
        if(MapUtils.isNotEmpty(lnkIds)){
            //
            PrjLnkCompQueryCondition queryCondition = new PrjLnkCompQueryCondition();
            queryCondition = qc;
            qc.setIdList(new ArrayList<>(lnkIds.keySet()));
            page.setCondition(qc);
            Pager pageOld = this.prjLnkCompService.searchListPage(page);
            //查询过征信的挂靠公司
            List<PrjLnkCompVO> creditList = (List<PrjLnkCompVO>) pageOld.getResultList();
            if(CollectionUtils.isNotEmpty(creditList)){
                for (PrjLnkCompVO prjLnkCompVO : creditList) {
                    if(lnkIds.containsKey(prjLnkCompVO.getId())){
                        prjLnkCompVO.setStarLevelNm(lnkIds.get(prjLnkCompVO.getId()));
                    }
                }
                queryCondition.setIdList(null);
                queryCondition.setNoIdList(new ArrayList<>(lnkIds.keySet()));
                page.setCondition(queryCondition);
                if("1".equals(currentPage)){
                    int size = page.getEveryPage() - creditList.size();
                    if(size > 0){
                        page.setEveryPage(size);
                        Pager pageNew = this.prjLnkCompService.searchListPage(page);
                        //第一页排除掉 前置的查询过征信的挂靠公司
                        List<PrjLnkCompVO> excludeCreditList = (List<PrjLnkCompVO>) pageNew.getResultList();
                        creditList.addAll(excludeCreditList);
                    }else{
                        creditList = creditList.subList(0,page.getEveryPage());
                    }
                }else{
                    Pager pageNew = this.prjLnkCompService.searchListPage(page);
                    //第一页排除掉 前置的查询过征信的挂靠公司
                    List<PrjLnkCompVO> excludeCreditList = (List<PrjLnkCompVO>) pageNew.getResultList();
                    creditList = excludeCreditList;
                }
                resList = creditList;
            }else{
                resList = list;
            }
        }else{
            resList = list;
        }
        for (PrjLnkCompVO prjLnkCompVO : resList) {
            if(rcCstChannelInfoDTOS == null || rcCstChannelInfoDTOS.size() == 0){
                prjLnkCompVO.setLnkCompMsg("未使用此挂靠公司查询狮桥分");
            }else{
                for (RcCstChannelInfoDTO rcCstChannelInfoDTO : rcCstChannelInfoDTOS) {
                    if(rcCstChannelInfoDTO.getChannelId().equals(prjLnkCompVO.getId())){
                        prjLnkCompVO.setLnkCompMsg(rcCstChannelInfoDTO.getDiscountInfo());
                        prjLnkCompVO.setLnkStartLvl(rcCstChannelInfoDTO.getSplStarLevel());
                    }else{
                        //如果为空才更新,不为空说明已经已经遍历过了
                        if(StringUtils.isBlank(prjLnkCompVO.getLnkCompMsg())){
                            prjLnkCompVO.setLnkCompMsg("未使用此挂靠公司查询狮桥分");
                        }
                    }
                }
            }

        }
        //2018-8-23 08:58:48 add
        if(CollectionUtils.isNotEmpty(resList)){
            //获取企业归属CODE-归属名称 MAP
            Map<String, String> ownerCdAndNmMap = this.sysDictionaryApiService.searchGroupToMap(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), fl.spl.facade.framework.constant.DictionaryConstant.SYS_LNK_OWNER_CODE_DIC_CD);

            List<Long> ids = new ArrayList<>(resList.size());

            for (PrjLnkCompVO prjLnkCompVO : resList) {
                Date expDt = prjLnkCompVO.getExpDt();
                long l = DateUtils.getDaysBetweenTwoDates(new Date(), expDt);
                if(l>15){
                    prjLnkCompVO.setIsValid(0);
                }else if(0<l && l<15){
                    prjLnkCompVO.setIsValid(1);
                }else{
                    prjLnkCompVO.setIsValid(2);
                }
                if(CollectionUtils.isMapNotEmpty(ownerCdAndNmMap) && ownerCdAndNmMap.containsKey(prjLnkCompVO.getOwnerCd())){
                    prjLnkCompVO.setOwnerCdNm(ownerCdAndNmMap.get(prjLnkCompVO.getOwnerCd()));
                }
                ids.add(prjLnkCompVO.getId());
            }
            ownerCdAndNmMap = null ;

            //初始化供应商星级信息
            Map<String, String> starLevelMap = sysDictionaryApiService.searchGroupToMap(SplSystemConstant.SPL_SYS_CD, SplSystemConstant.DEFAULT_ORG_CD, SplRateRelInfoConstant.SPL_RATE_STAR_DIC_CD);
            StringBuilder rpcSign = new StringBuilder();
            rpcSign.append(System.currentTimeMillis()).append("_").append(CurrentThreadContext.getCurrentUserName()).append("_").append(CurrentThreadContext.getCurrentUserId());
            SplRateRelInfoQC splRateRelInfoQC = new SplRateRelInfoQC();
            splRateRelInfoQC.setDataIdList(ids);
            splRateRelInfoQC.setTabNm("PRJ_LNK_COMP");
            splRateRelInfoQC.setIsNew(BaseConstant.IS_YESNO_YES);
            splRateRelInfoQC.setIsDel(BaseConstant.IS_YESNO_NO);
            splRateRelInfoQC.setIsValid(BaseConstant.IS_YESNO_YES);
            DataResultDTO resultDTO = this.splRateRelInfoQueryApiService.searchSplRateRelInfoDTOList(splRateRelInfoQC,SplSystemConstant.FL_WEB_CHL_CD, null,rpcSign.toString());
            BaseLogUtils.newWebLogger("查询挂靠公司星级信息.DATA:"+ JSONObject.toJSONString(resultDTO)).setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();
            if(BaseConstant.IS_YESNO_YES == resultDTO.getSuccess()){
                List<SplRateRelInfoDTO> splRateInfoList = (List<SplRateRelInfoDTO>)resultDTO.getData() ;
                if(CollectionUtils.isNotEmpty(splRateInfoList)){
                    Map<Long,Long> splIdByStarLevelMap = new HashMap<>();
                    for (SplRateRelInfoDTO rateRelDTO:splRateInfoList) {
                        splIdByStarLevelMap.put(rateRelDTO.getDataId(),rateRelDTO.getStarLevel());
                    }
                    for (PrjLnkCompVO vo:resList) {
                        Long levelCd = splIdByStarLevelMap.get(vo.getId());
                        if(StringUtils.isNotEmpty(levelCd)) {
                            vo.setStarLevelNm(starLevelMap.get(levelCd.toString()));
                        }
                    }
                }
            }
        }
        ListPageVO<PrjLnkCompVO> listPage = new ListPageVO<PrjLnkCompVO>(resList, pager.getTotalCount());
        BaseLogUtils.newWebLogger("获取挂靠公司数据完成").setLogOperType(LogOperEnum.RESP)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                .setWarning(false)
                .setKeys("listPage", JSON.toJSONString(listPage))
                .info();
        return listPage;
    }

    /**
     * 新增时判断是否已经有了,如果有了前台判断是否要带入已有信息
     */
    @RequestMapping(value = "/getExistComp.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object getExistComp(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
        String lnkCompNm = request.getParameter("lnkCompNm");//公司名称
        
        if(StringUtils.isEmpty(lnkCompNm)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
            BaseLogUtils.newWebLogger("校验挂靠公司是否已存在失败,挂靠公司名称为空！").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .warn(LogExceptionEnum.COMMON_CODE_0002);
			return result;
		}
        
        try {
            //新增前需要先检查系统是否存在用户信息
            PrjLnkCompQueryCondition condition = new PrjLnkCompQueryCondition();
            condition.setLnkCompRlNm(lnkCompNm);
            //SplCommBasicDTO  splCommBasicDTO = null;
            HsjBasicDTO hsjBasicDTO = null ;
            List<PrjLnkCompVO> compList = this.prjLnkCompService.getPrjLnkCompByCondition(condition);
            if (CollectionUtils.isEmpty(compList)) {// 我司库中不存在该公司
                // 查询工商基础信息
                /*SplCommBasicQC splCommBasicQC = new SplCommBasicQC();
                splCommBasicQC.setEntname(lnkCompNm);
                splCommBasicDTO = this.splCommBasicApiService.getCommInfoByNameAndType("2", lnkCompNm, 3, null);*/
                //三方数据关停
            	//hsjBasicDTO = this.hsjQueryService.getCommInfoByNameAndType(BaseConstant.IS_YESNO_YES_STR, lnkCompNm);
                // 查询结果为空,则提示"请前检查输入公司名称是否正确"; 不为空则将结果带入编辑页
                /*if (null == hsjBasicDTO || StringUtils.isEmpty(hsjBasicDTO.getEntName())) {
                	result.setInfo(BaseConstant.IS_YESNO_NO_STR);
					return result;
                } else {*/
                	result.setInfo(BaseConstant.IS_YESNO_YES_STR);
                	/*result.setData(hsjBasicDTO.getId());
                    BaseLogUtils.newWebLogger("读取工商信息成功!").setLogOperType(LogOperEnum.RESP)
                            .setSysCd(CurrentThreadContext.getCurrentSysCd())
                            .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                            .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                            .setWarning(false)
                            .setKeys("hsjBasicDTO", JSON.toJSONString(hsjBasicDTO))
                            .info();*/
					return result;
                //}
            } else {// 我司库中存在该公司
            	PrjLnkCompVO prjLnkCompVO = compList.get(0);
            	if (null != prjLnkCompVO) {
					result.setId(prjLnkCompVO.getId());
				}
            	
                condition = new PrjLnkCompQueryCondition();
                condition.setLnkCompRlNm(lnkCompNm);
                //condition.setAudStsCdList(audStsCdList);
                //condition.setIsSplitQueryAudStsCd(BaseConstant.IS_YESNO_NO_STR);
                condition.setIsDel(BaseConstant.IS_YESNO_NO);
                List<PrjLnkCompVO> flowCompList = this.prjLnkCompService.getPrjLnkCompByCondition(condition);
                if (CollectionUtils.isNotEmpty(flowCompList)) {
                    List<String> audStsCdList = new ArrayList<String>();
                    audStsCdList.add(CommonAudStsCdEnum.PASS.getStatus());
                    audStsCdList.add(CommonAudStsCdEnum.REJECT.getStatus());
                    audStsCdList.add(CommonAudStsCdEnum.CHECKING.getStatus());
                    audStsCdList.add(CommonAudStsCdEnum.INCHANGE.getStatus());
                    if(audStsCdList.contains(flowCompList.get(BaseConstant.IS_YESNO_NO).getAudStsCd())){
                        //审核中或者审核通过或者变更中
                        result.setSuccess(BaseConstant.IS_YESNO_NO);
    					result.setInfo("挂靠公司在审核中或者审核通过,不允许进行修改!");
                        BaseLogUtils.newWebLogger("挂靠公司在审核中或者审核通过,不允许进行修改!").setLogOperType(LogOperEnum.RESP)
                                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                                .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                                .setWarning(false)
                                .warn(LogExceptionEnum.COMMON_CODE_0002);
                    }else{
                        //审核不通过或者待提交
                        result.setInfo("信息已存在,跳转到修改页面!");
                    }
                } else {
                    //审核不通过或者待提交
                	result.setInfo("信息已存在,跳转到修改页面!");
                }
            }

        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.newWebLogger("校验挂靠公司信息失败,业务异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .warn(LogExceptionEnum.COMMON_CODE_0001);
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.newWebLogger("校验挂靠公司信息失败,系统异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .error(LogExceptionEnum.COMMON_CODE_0099);
        }
        return result;
    }

    /**
     * 修改挂靠公司审核状态
     */
    @RequestMapping(value = "/modifyAudStsCd.do", method = {RequestMethod.POST})
    @ResponseBody
    public DataResultVO modifyAudStsCd(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        String audStsCd = request.getParameter("audStsCd");
        String id = request.getParameter("id");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
        if (StringUtils.isEmpty(id) || StringUtils.isEmpty(audStsCd)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
            BaseLogUtils.newWebLogger("修改挂靠公司审核状态,参数不完整！").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .warn(LogExceptionEnum.COMMON_CODE_0002);
            return result;
        }
        try {
            boolean success = this.prjLnkCompService.modifyAudStsCd(Long.valueOf(id), audStsCd);
            if (!success) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo(SysLogConstant.LOG_CMM_DELETE_FAIL);
            }
            BaseLogUtils.newWebLogger("修改挂靠公司审核状态").setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setKeys("result", JSON.toJSONString(result))
                    .info();
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.newWebLogger("修改挂靠公司审核状态失败,业务异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .warn(LogExceptionEnum.COMMON_CODE_0001);
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.newWebLogger("修改挂靠公司审核状态失败,系统异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .error(LogExceptionEnum.COMMON_CODE_0099);
        }

        return result;
    }

    /**
     * 删除数据
     */
    @RequestMapping(value = "/removeByIds.do", method = {RequestMethod.POST})
    @ResponseBody
    public DataResultVO removeById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        String ids = request.getParameter("ids");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_DELETE_SUCC);
        if (StringUtils.isEmpty(ids)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
            return result;
        }
        List<Long> idList = new ArrayList<Long>();
        JSONArray idsArray = JSONArray.fromObject(ids);
        for (Object object : idsArray) {
            idList.add(Long.valueOf(object.toString()));
        }
        try {
            this.prjLnkCompService.removeByIds(idList);
            BaseLogUtils.newWebLogger("删除挂靠公司数据").setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setKeys("result", JSON.toJSONString(result))
                    .info();
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.newWebLogger("删除挂靠公司数据失败,业务异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .warn(LogExceptionEnum.COMMON_CODE_0001);
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.newWebLogger("删除挂靠公司数据失败,系统异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .error(LogExceptionEnum.COMMON_CODE_0099);
        }
        result.setSuccess(BaseConstant.IS_YESNO_YES);
        return result;
    }

    /**
     * 得到一条记录
     *
     * @param request
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getById.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object getById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        String id = request.getParameter("id");
        String isMaskStr = request.getParameter("isMask");
        int isMask = 0 ;
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
        if (StringUtils.isEmpty(id)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
            BaseLogUtils.newWebLogger("获取挂靠公司数据详情,id为空").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .warn(LogExceptionEnum.COMMON_CODE_0002);
            return result;
        }
        //根据角色查询是否需要掩码  1是0否
        String roleisEncrypt = this.sysDictionaryService.getRoleisEncrypt();
        if(StringUtils.isNotEmpty(isMaskStr) && BaseConstant.IS_YESNO_YES_STR.equals(isMaskStr) 
        		&& BaseConstant.IS_YESNO_YES_STR.equals(roleisEncrypt)){
        	isMask = 1 ;
        }
        
        try {
            PrjLnkCompVO vo = this.prjLnkCompService.selectPrjLnkCompByIdAndIsMask(Long.valueOf(id), isMask);
            if (null == vo) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo(SysLogConstant.LOG_CMM_QUERY_DATA_IS_EMPTY);
                BaseLogUtils.newWebLogger("获取挂靠公司数据不存在!").setLogOperType(LogOperEnum.RESP)
                        .setSysCd(CurrentThreadContext.getCurrentSysCd())
                        .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                        .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                        .setWarning(false)
                        .warn(LogExceptionEnum.COMMON_CODE_0002);
            }
            ListPageVO<PrjLnkCompRlPsnVO> rlPsnList = new ListPageVO<PrjLnkCompRlPsnVO>(vo.getRlPsnList(), vo.getRlPsnList().size());
            if (null != rlPsnList && rlPsnList.getTotal() >= 0) {
                vo.setRlPsnListPage(rlPsnList);
            }
            if(StringUtils.isNotEmpty(vo.getIsRecycleLoa())){
				vo.setIsRecycleLoaNm(vo.getIsRecycleLoa() == 1? "是":"否");
			}
			if(StringUtils.isNotEmpty(vo.getIsUploadLoa())){
				vo.setIsUploadLoaNm(vo.getIsUploadLoa() == 1? "是":"否");
			}
            if(SplGrpRelInfoSrcEnum.SRC_QIANHAI.getRelInfoSrc().equals(vo.getImportDataSource()) && BaseConstant.IS_YESNO_NO == vo.getImportDataIsChange()){
            	vo.setDataFromNm("带入");
            }else{
            	vo.setDataFromNm("手填");
            }
            
            result.setData(vo);
            BaseLogUtils.newWebLogger("获取挂靠公司数据详情").setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setKeys("result", JSON.toJSONString(result))
                    .info();
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.newWebLogger("获取挂靠公司数据失败,业务异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .warn(LogExceptionEnum.COMMON_CODE_0001);
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.newWebLogger("获取挂靠公司数据失败,系统异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .error(LogExceptionEnum.COMMON_CODE_0099);
        }
        return result;
    }

    /**
     * 检查是否重名
     *
     * @param request
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/checkPrjLnkCompNm.do", method = {RequestMethod.GET,RequestMethod.POST})
    @ResponseBody
    public Object checkPrjLnkCompNm(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        String name = request.getParameter("lnkCompNm");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "该挂靠公司已经存在！");
        if (StringUtils.isBlank(name)) {
            throw new BaseException(BaseExceptionConstant.COMMON_0001, BaseExceptionConstant.COMMON_0001_NAME);
        }
        try {
            PrjLnkCompQueryCondition qc = new PrjLnkCompQueryCondition();
            qc.setLnkCompRlNm(name);
            qc.setIsDel(BaseConstant.IS_YESNO_NO);
            List<PrjLnkCompVO> prjLnkCompList = this.prjLnkCompService.getPrjLnkCompByCondition(qc);
            if (null == prjLnkCompList || prjLnkCompList.size() == 0) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo(SysLogConstant.LOG_CMM_QUERY_DATA_IS_EMPTY);
                BaseLogUtils.newWebLogger("获取挂靠公司数据不存在!").setLogOperType(LogOperEnum.RESP)
                        .setSysCd(CurrentThreadContext.getCurrentSysCd())
                        .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                        .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                        .setWarning(false)
                        .warn(LogExceptionEnum.COMMON_CODE_0002);
            }
            result.setData(prjLnkCompList);
            BaseLogUtils.newWebLogger("获取挂靠公司数据详情").setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setKeys("result", JSON.toJSONString(result))
                    .info();
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.newWebLogger("获取挂靠公司数据失败,业务异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .warn(LogExceptionEnum.COMMON_CODE_0001);
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.newWebLogger("获取挂靠公司数据失败,系统异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .error(LogExceptionEnum.COMMON_CODE_0099);
        }
        return result;
    }


    /**
     * 新增
     */
    @RequestMapping(value = "/addPrjLnkComp.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object add(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        BaseLogUtils.newWebLogger("新增挂靠公司开始").setLogOperType(LogOperEnum.REQ)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                .setWarning(false)
                .setKeys("request", this.getRequestParameter(request))
                .info();
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_ADD_SUCC);
        PrjLnkCompVO prjLnkCompVO = null;
        String lnkCompId = request.getParameter("lnkCompId");
        String reason = request.getParameter("reason");// 操作原因
        String propCd = request.getParameter("propCd");
        String validTmStar = request.getParameter("validTmStar");
        String validTmEnd = request.getParameter("validTmEnd");
        String roadBicycleRate = request.getParameter("roadBicycleRate");
        String stopTruckRate = request.getParameter("stopTruckRate");
        String fileParams = request.getParameter("propFileParams");
        String ownerCd = request.getParameter("ownerCd");
        Long id = null;

        try {
            this.prjLnkCompService.checkLnkFiles(request);
            prjLnkCompVO = getPrjLnkCompParam(request);
            if (StringUtils.isNotBlank(lnkCompId)) {
                id = Long.valueOf(lnkCompId) ;

                PrjLnkCompQueryCondition lnkCompQueryQC = new PrjLnkCompQueryCondition();
            	lnkCompQueryQC.setLnkCompRlNm(prjLnkCompVO.getLnkCompNm());
				List<PrjLnkCompVO> lnkCompListByNm = this.prjLnkCompService.getPrjLnkCompByCondition(lnkCompQueryQC );
				if(CollectionUtils.isNotEmpty(lnkCompListByNm)){
					for (PrjLnkCompVO prjLnkCompVO2 : lnkCompListByNm) {
						if(!id.equals(prjLnkCompVO2.getId())){
							result.setSuccess(BaseConstant.IS_YESNO_NO);
							result.setInfo("挂靠公司已存在！");
							return result ;
						}
					}
				}
				lnkCompQueryQC = new PrjLnkCompQueryCondition();
				lnkCompQueryQC.setSucc(prjLnkCompVO.getSucc());
				List<PrjLnkCompVO> lnkCompListBySucc = this.prjLnkCompService.getPrjLnkCompByCondition(lnkCompQueryQC );
				if(CollectionUtils.isNotEmpty(lnkCompListBySucc)){
					for (PrjLnkCompVO prjLnkCompVO2 : lnkCompListBySucc) {
						if(!id.equals(prjLnkCompVO2.getId())){
							result.setSuccess(BaseConstant.IS_YESNO_NO);
							result.setInfo("挂靠公司社会统一信用代码重复！");
							return result ;
						}
					}
				}

                //修改挂靠公司
                prjLnkCompVO.setId(id);
                this.prjLnkCompService.modify(prjLnkCompVO);

                //添加操作日志
                try {
    				if (StringUtils.isNotEmpty(reason)) {
						Long add = this.splOpLogRecService.add(lnkCompId, reason, SplRelLogOpTypCdNum.MDF.getOpTypCd(), SplRelLogBizTypCdNum.LNK.getBizTypCd());
					}
    			} catch (BaseException e) {
                    BaseLogUtils.newWebLogger("插入供应商操作记录失败,业务异常").setLogOperType(LogOperEnum.REQ)
                            .setSysCd(CurrentThreadContext.getCurrentSysCd())
                            .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                            .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                            .setWarning(false)
                            .setThrowable(e)
                            .warn(LogExceptionEnum.COMMON_CODE_0001);
    			}
                
                PrjLnkCompOrgRQC qc = new PrjLnkCompOrgRQC();
                qc.setLnkCompId(Long.valueOf(lnkCompId));
                qc.setBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
                List<PrjLnkCompOrgRVO> rs = this.prjLnkCompOrgRService.searchList(qc);
                if (CollectionUtils.isEmpty(rs)) {
                    PrjLnkCompOrgRVO prjLnkCompOrg = new PrjLnkCompOrgRVO();
                    prjLnkCompOrg.setLnkCompId(Long.valueOf(lnkCompId));
                    prjLnkCompOrg.setBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
                    this.prjLnkCompOrgRService.add(prjLnkCompOrg);
                }
                result.setSuccess(BaseConstant.IS_YESNO_YES);
                result.setInfo(SysLogConstant.LOG_CMM_UPDATE_SUCC);
            } else {
            	PrjLnkCompQueryCondition lnkCompQueryQC = new PrjLnkCompQueryCondition();
            	lnkCompQueryQC.setLnkCompRlNm(prjLnkCompVO.getLnkCompNm());
				List<PrjLnkCompVO> lnkCompListByNm = this.prjLnkCompService.getPrjLnkCompByCondition(lnkCompQueryQC );
				if(CollectionUtils.isNotEmpty(lnkCompListByNm)){
					result.setSuccess(BaseConstant.IS_YESNO_NO);
					result.setInfo("挂靠公司已存在，请勿重复添加！");
					return result ;
				}
				lnkCompQueryQC = new PrjLnkCompQueryCondition();
				lnkCompQueryQC.setSucc(prjLnkCompVO.getSucc());
				List<PrjLnkCompVO> lnkCompListBySucc = this.prjLnkCompService.getPrjLnkCompByCondition(lnkCompQueryQC );
				if(CollectionUtils.isNotEmpty(lnkCompListBySucc)){
					result.setSuccess(BaseConstant.IS_YESNO_NO);
					result.setInfo("挂靠公司社会统一信用代码重复！");
					return result ;
				}
                //获取页面参数
                prjLnkCompVO.setCrtTm(new Date());
                prjLnkCompVO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
                prjLnkCompVO.setIsDel(BaseConstant.IS_YESNO_NO);
                prjLnkCompVO.setAudStsCd(PrjLnkCompRelInfoConstant.CODE_AUD_STS_NOT_AUDI_CD);//获取默认的审核状态
                id = this.prjLnkCompService.add(prjLnkCompVO);
                //添加操作日志
                try {
    				if (StringUtils.isNotEmpty(reason)) {
						Long add = this.splOpLogRecService.add(id.toString(), reason, SplRelLogOpTypCdNum.ADD.getOpTypCd(), SplRelLogBizTypCdNum.LNK.getBizTypCd());
					}
    			} catch (BaseException e) {
                    BaseLogUtils.newWebLogger("插入供应商操作记录失败,业务异常").setLogOperType(LogOperEnum.REQ)
                            .setSysCd(CurrentThreadContext.getCurrentSysCd())
                            .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                            .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                            .setWarning(false)
                            .setThrowable(e)
                            .warn(LogExceptionEnum.COMMON_CODE_0001);
                }
                
                PrjLnkCompOrgRQC qc = new PrjLnkCompOrgRQC();
                qc.setLnkCompId(id);
                qc.setBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
                List<PrjLnkCompOrgRVO> rs = this.prjLnkCompOrgRService.searchList(qc);
                if (CollectionUtils.isEmpty(rs)) {
                    PrjLnkCompOrgRVO prjLnkCompOrg = new PrjLnkCompOrgRVO();
                    prjLnkCompOrg.setLnkCompId(id);
                    prjLnkCompOrg.setBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
                    this.prjLnkCompOrgRService.add(prjLnkCompOrg);
                }

            }
            List<SplCommPropInfoVO> splCommPropInfoVOS = null ;
            if(StringUtils.isNotEmpty(propCd) && "2".equals(ownerCd)){
                if(StringUtils.isEmpty(validTmStar)){
                    throw new BaseException(BaseExceptionConstant.COMMON_0001, "请填写协议担保有效期！");
                }
                if(StringUtils.isEmpty(validTmEnd)){
                    throw new BaseException(BaseExceptionConstant.COMMON_0001, "请填写协议担保有效期！");
                }
                splCommPropInfoVOS = new ArrayList<>();
                String[] propArray = propCd.split(";");
                SplCommPropInfoVO propVO ;
                for (String prop:propArray) {
                    propVO = new SplCommPropInfoVO();
                    propVO.setDataId(Long.valueOf(id));
                    propVO.setPropInfo(prop);
                    propVO.setPropTypCd("002");
                    propVO.setIsDel(BaseConstant.IS_YESNO_NO);
                    propVO.setIsValid(BaseConstant.IS_YESNO_YES);
                    propVO.setCrtTm(new Date());
                    propVO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
                    splCommPropInfoVOS.add(propVO);
                }
                if(propCd.contains("9")) {
                    SplCarsGuarDtlInfoDTO carsGuarDtlInfoDTO = null;
                    SplCarsGuarDtlInfoQC qc = new SplCarsGuarDtlInfoQC();
                    qc.setIsValid(BaseConstant.IS_YESNO_YES);
                    qc.setLnkId(Long.valueOf(id));
                    qc.setIsDel(BaseConstant.IS_YESNO_NO);
                    List<SplCarsGuarDtlInfoDTO> dtlInfoDTOS = this.splCarsGuarDtlInfoApiService.searchList(qc);
                    if (CollectionUtils.isNotEmpty(dtlInfoDTOS)) {
                        carsGuarDtlInfoDTO = dtlInfoDTOS.get(0);
                        carsGuarDtlInfoDTO.setValidTmStar(DateUtils.formatStringToDate(validTmStar, DateUtils.YYYY_MM_DD));
                        carsGuarDtlInfoDTO.setValidTmEnd(DateUtils.formatStringToDate(validTmEnd, DateUtils.YYYY_MM_DD));
                        DecimalFormat df = new DecimalFormat("#.00");
                        if (StringUtils.isNotEmpty(roadBicycleRate)) {
                            carsGuarDtlInfoDTO.setRoadBicycleRate(Double.valueOf(df.format(Double.valueOf(roadBicycleRate))));
                        }
                        if (StringUtils.isNotEmpty(stopTruckRate)) {
                            carsGuarDtlInfoDTO.setStopTruckRate(Double.valueOf(df.format(Double.valueOf(stopTruckRate))));
                        }
                        carsGuarDtlInfoDTO.setMdfTm(new Date());
                        carsGuarDtlInfoDTO.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
                        this.splCarsGuarDtlInfoApiService.modify(carsGuarDtlInfoDTO);
                    } else {
                        carsGuarDtlInfoDTO = new SplCarsGuarDtlInfoDTO();
                        carsGuarDtlInfoDTO.setValidTmStar(DateUtils.formatStringToDate(validTmStar, DateUtils.YYYY_MM_DD));
                        carsGuarDtlInfoDTO.setValidTmEnd(DateUtils.formatStringToDate(validTmEnd, DateUtils.YYYY_MM_DD));
                        DecimalFormat df = new DecimalFormat("#.00");
                        if (StringUtils.isNotEmpty(roadBicycleRate)) {
                            carsGuarDtlInfoDTO.setRoadBicycleRate(Double.valueOf(df.format(Double.valueOf(roadBicycleRate))));
                        } else {
                            carsGuarDtlInfoDTO.setRoadBicycleRate(5.00D);
                        }
                        if (StringUtils.isNotEmpty(stopTruckRate)) {
                            carsGuarDtlInfoDTO.setStopTruckRate(Double.valueOf(df.format(Double.valueOf(stopTruckRate))));
                        } else {
                            carsGuarDtlInfoDTO.setStopTruckRate(5.00D);
                        }
                        carsGuarDtlInfoDTO.setIsDel(BaseConstant.IS_YESNO_NO);
                        carsGuarDtlInfoDTO.setIsValid(BaseConstant.IS_YESNO_YES);
                        carsGuarDtlInfoDTO.setCrtTm(new Date());
                        carsGuarDtlInfoDTO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
                        carsGuarDtlInfoDTO.setLnkId(Long.valueOf(id));
                        this.splCarsGuarDtlInfoApiService.add(carsGuarDtlInfoDTO);
                    }

                    if (StringUtils.isNotBlank(fileParams)) {
                        List<PrjFileInfoVO> fileParamList = JSON.parseArray(fileParams, PrjFileInfoVO.class);
                        if (CollectionUtils.isNotEmpty(fileParamList)) {
                            BaseLogUtils.newLogger("附件信息").setKeys("fileParamList.size()", fileParamList.size() + "").info();
                            List<SysUlFilesRecDTO> addFileList = new ArrayList<>();
                            List<SysUlFilesRecDTO> modifyFileList = new ArrayList<>();

                            SysUlFilesRecDTO filesRecDTO;
                            List<String> cfgDtlList = new ArrayList<>();
                            for (PrjFileInfoVO fileInfoVO : fileParamList) {
                                cfgDtlList.add(fileInfoVO.getCfgDtlCd());
                            }
                            for (PrjFileInfoVO fileInfoVO : fileParamList) {
                                filesRecDTO = new SysUlFilesRecDTO();
                                filesRecDTO.setFilePath(fileInfoVO.getFilePath());
                                filesRecDTO.setFileNm(fileInfoVO.getFileNm());
                                filesRecDTO.setCfgCd(SplInfoFileCfgEnum.PRJ034.getCode());
                                filesRecDTO.setTabNm(SplInfoFileCfgEnum.PRJ034.getTableNm());
                                filesRecDTO.setSysCd(SplInfoFileCfgEnum.PRJ034.getSysCd());
                                filesRecDTO.setCfgDtlCd(fileInfoVO.getCfgDtlCd());
                                filesRecDTO.setOrgCd(fileInfoVO.getOrgCd());
                                filesRecDTO.setAbsLocPath(PropertiesCacheUtils.getProperty(SplInfoFileCfgEnum.PRJ034.getUploadRootPath()) + filesRecDTO.getFilePath());
                                filesRecDTO.setCrtTm(new Date());
                                filesRecDTO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
                                filesRecDTO.setIsDel(BaseConstant.IS_YESNO_NO);
                                //默认验证状态:未验证
                                filesRecDTO.setAudStsCd(PropertiesCacheUtils.getProperty(fl.constant.facade.framework.constant.DictionaryConstant.CODE_GRP_VALID_STATUS_CD_A));
                                filesRecDTO.setPkId(id + "");
                                if (StringUtils.isNotEmpty(fileInfoVO.getFileId())) {
                                    filesRecDTO.setId(fileInfoVO.getFileId());
                                    modifyFileList.add(filesRecDTO);
                                } else {
                                    addFileList.add(filesRecDTO);
                                }
                            }
                            if (CollectionUtils.isNotEmpty(addFileList)) {
                                this.uploadApiService.addSysUlFilesRecList(addFileList);
                            }
                            if (CollectionUtils.isNotEmpty(modifyFileList)) {
                                this.uploadApiService.modifySysUlFilesRecList(modifyFileList);
                            }
                        } else {
                            throw new BaseException(BaseExceptionConstant.COMMON_0001, "请上传附件信息！");
                        }
                    } else {
                        throw new BaseException(BaseExceptionConstant.COMMON_0001, "请上传附件信息！");
                    }
                }
            }else{
                SplCommPropInfoQC propQC = new SplCommPropInfoQC();
                propQC.setDataId(id);
                propQC.setPropTypCd("002");
                propQC.setIsValid(BaseConstant.IS_YESNO_YES);
                propQC.setIsDel(BaseConstant.IS_YESNO_NO);
                List<SplCommPropInfoDTO> propInfoDTOList = this.splCommPropInfoApiService.searchList(propQC);
                if(CollectionUtils.isNotEmpty(propInfoDTOList)){
                    for (SplCommPropInfoDTO commPropInfoDTO:propInfoDTOList) {
                        splCommPropInfoApiService.removeById(commPropInfoDTO.getId());
                    }
                }
                SplCarsGuarDtlInfoDTO carsGuarDtlInfoDTO = null;
                SplCarsGuarDtlInfoQC qc = new SplCarsGuarDtlInfoQC();
                qc.setIsValid(BaseConstant.IS_YESNO_YES);
                qc.setLnkId(Long.valueOf(id));
                qc.setIsDel(BaseConstant.IS_YESNO_NO);
                List<SplCarsGuarDtlInfoDTO> dtlInfoDTOS2 = this.splCarsGuarDtlInfoApiService.searchList(qc);
                if(CollectionUtils.isNotEmpty(dtlInfoDTOS2)){
                    for (SplCarsGuarDtlInfoDTO splCarsGuarDtlInfoDTO:dtlInfoDTOS2) {
                        splCarsGuarDtlInfoApiService.removeById(splCarsGuarDtlInfoDTO.getId());
                    }
                }
            }
            if(CollectionUtils.isNotEmpty(splCommPropInfoVOS)){
                splCommPropInfoApiService.batchAdd(SplCommPropInfoVOTransform.toDTOList(splCommPropInfoVOS));
            }
            result.setData(id);
            BaseLogUtils.newWebLogger("新增挂靠公司").setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setKeys("result", JSON.toJSONString(result))
                    .info();
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.newWebLogger("新增挂靠公司失败,业务异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .warn(LogExceptionEnum.COMMON_CODE_0001);
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.newWebLogger("新增挂靠公司失败,系统异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .error(LogExceptionEnum.COMMON_CODE_0099);
        }
        return result;
    }



    /**
     * 修改
     */
    @RequestMapping(value = "/modify.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object modify(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        String id = request.getParameter("id");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_UPDATE_SUCC);
        if (StringUtils.isEmpty(id)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
            BaseLogUtils.newWebLogger("修改挂靠公司数据,id为空").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .warn(LogExceptionEnum.COMMON_CODE_0002);
            return result;
        }
        PrjLnkCompVO prjLnkCompVO = null;
        try {
            //获取页面参数
            prjLnkCompVO = getPrjLnkCompParam(request);
            prjLnkCompVO.setId(Long.valueOf(id));
            String propCd = request.getParameter("propCd");
            String validTmStar = request.getParameter("validTmStar");
            String validTmEnd = request.getParameter("validTmEnd");
            String roadBicycleRate = request.getParameter("roadBicycleRate");
            String stopTruckRate = request.getParameter("stopTruckRate");
            String fileParams = request.getParameter("propFileParams");
            List<SplCommPropInfoVO> splCommPropInfoVOS = null;
            Long carsGuarId = null ;
            if(StringUtils.isNotEmpty(propCd)){
                if(StringUtils.isEmpty(validTmStar)){
                    throw new BaseException(BaseExceptionConstant.COMMON_0001, "请填写协议担保有效期！");
                }
                if(StringUtils.isEmpty(validTmEnd)){
                    throw new BaseException(BaseExceptionConstant.COMMON_0001, "请填写协议担保有效期！");
                }
                splCommPropInfoVOS = new ArrayList<>();
                String[] propArray = propCd.split(",");
                SplCommPropInfoVO propVO ;
                for (String prop:propArray) {
                    propVO = new SplCommPropInfoVO();
                    propVO.setDataId(Long.valueOf(id));
                    propVO.setPropInfo(prop);
                    propVO.setPropTypCd("002");
                    propVO.setIsDel(BaseConstant.IS_YESNO_NO);
                    propVO.setIsValid(BaseConstant.IS_YESNO_YES);
                    propVO.setCrtTm(new Date());
                    propVO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
                    splCommPropInfoVOS.add(propVO);
                }
                SplCarsGuarDtlInfoDTO carsGuarDtlInfoDTO = null ;
                SplCarsGuarDtlInfoQC qc = new SplCarsGuarDtlInfoQC();
                qc.setIsValid(BaseConstant.IS_YESNO_YES);
                qc.setLnkId(Long.valueOf(id));
                qc.setIsDel(BaseConstant.IS_YESNO_NO);
                List<SplCarsGuarDtlInfoDTO> dtlInfoDTOS = this.splCarsGuarDtlInfoApiService.searchList(qc);
                if(CollectionUtils.isNotEmpty(dtlInfoDTOS)){
                    carsGuarDtlInfoDTO = dtlInfoDTOS.get(0);
                    carsGuarDtlInfoDTO.setValidTmStar(DateUtils.formatStringToDate(validTmStar,DateUtils.YYYY_MM_DD));
                    carsGuarDtlInfoDTO.setValidTmEnd(DateUtils.formatStringToDate(validTmEnd,DateUtils.YYYY_MM_DD));
                    carsGuarDtlInfoDTO.setMdfTm(new Date());
                    carsGuarDtlInfoDTO.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
                    this.splCarsGuarDtlInfoApiService.modify(carsGuarDtlInfoDTO);
                }else{
                    carsGuarDtlInfoDTO = new SplCarsGuarDtlInfoDTO();
                    carsGuarDtlInfoDTO.setValidTmStar(DateUtils.formatStringToDate(validTmStar,DateUtils.YYYY_MM_DD));
                    carsGuarDtlInfoDTO.setValidTmEnd(DateUtils.formatStringToDate(validTmEnd,DateUtils.YYYY_MM_DD));
                    carsGuarDtlInfoDTO.setCrtTm(new Date());
                    carsGuarDtlInfoDTO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
                    carsGuarDtlInfoDTO.setLnkId(Long.valueOf(id));
                    this.splCarsGuarDtlInfoApiService.add(carsGuarDtlInfoDTO);
                }

                if (StringUtils.isNotBlank(fileParams)) {
                    List<PrjFileInfoVO> fileParamList = JSON.parseArray(fileParams, PrjFileInfoVO.class);
                    if(CollectionUtils.isNotEmpty(fileParamList)){
                        BaseLogUtils.newLogger("附件信息").setKeys("fileParamList.size()",fileParamList.size()+"").info();
                        List<SysUlFilesRecDTO> addFileList = new ArrayList<>();
                        List<SysUlFilesRecDTO> modifyFileList = new ArrayList<>();

                        SysUlFilesRecDTO filesRecDTO ;
                        List<String> cfgDtlList = new ArrayList<>();
                        for (PrjFileInfoVO fileInfoVO : fileParamList) {
                            cfgDtlList.add(fileInfoVO.getCfgDtlCd());
                        }
                        for (PrjFileInfoVO fileInfoVO : fileParamList) {
                            filesRecDTO = new SysUlFilesRecDTO();
                            filesRecDTO.setFilePath(fileInfoVO.getFilePath());
                            filesRecDTO.setFileNm(fileInfoVO.getFileNm());
                            filesRecDTO.setCfgCd(SplInfoFileCfgEnum.PRJ034.getCode());
                            filesRecDTO.setTabNm(SplInfoFileCfgEnum.PRJ034.getTableNm());
                            filesRecDTO.setSysCd(SplInfoFileCfgEnum.PRJ034.getSysCd());
                            filesRecDTO.setCfgDtlCd(fileInfoVO.getCfgDtlCd());
                            filesRecDTO.setOrgCd(fileInfoVO.getOrgCd());
                            filesRecDTO.setAbsLocPath(PropertiesCacheUtils.getProperty(SplInfoFileCfgEnum.PRJ034.getUploadRootPath())+filesRecDTO.getFilePath());
                            filesRecDTO.setCrtTm(new Date());
                            filesRecDTO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
                            filesRecDTO.setIsDel(BaseConstant.IS_YESNO_NO);
                            //默认验证状态:未验证
                            filesRecDTO.setAudStsCd(PropertiesCacheUtils.getProperty(fl.constant.facade.framework.constant.DictionaryConstant.CODE_GRP_VALID_STATUS_CD_A));
                            filesRecDTO.setPkId(id);
                            if (StringUtils.isNotEmpty(fileInfoVO.getFileId())) {
                                filesRecDTO.setId(fileInfoVO.getFileId());
                                modifyFileList.add(filesRecDTO);
                            }else{
                                addFileList.add(filesRecDTO);
                            }
                        }
                        if(CollectionUtils.isNotEmpty(addFileList)){
                            this.uploadApiService.addSysUlFilesRecList(addFileList);
                        }
                        if(CollectionUtils.isNotEmpty(modifyFileList)){
                            this.uploadApiService.modifySysUlFilesRecList(modifyFileList);
                        }
                    }else{
                        throw new BaseException(BaseExceptionConstant.COMMON_0001, "请上传附件信息！");
                    }
                }else{
                    throw new BaseException(BaseExceptionConstant.COMMON_0001, "请上传附件信息！");
                }
            }
            boolean success = this.prjLnkCompService.modify(prjLnkCompVO);
            if(CollectionUtils.isNotEmpty(splCommPropInfoVOS)){
                splCommPropInfoApiService.batchAdd(SplCommPropInfoVOTransform.toDTOList(splCommPropInfoVOS));
            }

            if (!success) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
                BaseLogUtils.newWebLogger("修改挂靠公司数据不存在!").setLogOperType(LogOperEnum.RESP)
                        .setSysCd(CurrentThreadContext.getCurrentSysCd())
                        .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                        .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                        .setWarning(false)
                        .warn(LogExceptionEnum.COMMON_CODE_0002);
            }
            BaseLogUtils.newWebLogger("修改挂靠公司数据").setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setKeys("result", JSON.toJSONString(result))
                    .info();
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.newWebLogger("修改挂靠公司数据失败,业务异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .warn(LogExceptionEnum.COMMON_CODE_0001);
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.newWebLogger("修改挂靠公司数据失败,系统异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .error(LogExceptionEnum.COMMON_CODE_0099);
        }
        return result;
    }


    /**
     * 发起流程
     */
    @RequestMapping(value = "/addFlowStart.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object addFlowStart(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        //DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_ADD_SUCC);
        String prjLnkCompId = request.getParameter("prjLnkCompId");
        DataResultVO resultVO = new DataResultVO(BaseConstant.IS_YESNO_YES);
        try {
            boolean checkBlack = this.prjLnkCompQueryApiService.checkLnkCompIsBlack(Long.valueOf(prjLnkCompId),CurrentThreadContext.getCurrentSysCd(),CurrentThreadContext.getCurrentOrgCd());
            if(checkBlack){
                resultVO.setInfo("当前挂靠公司存在黑名单，无法发起准入流程！");
                resultVO.setSuccess(BaseConstant.IS_YESNO_NO);
                return resultVO ;
            }
            resultVO = this.prjLnkCompService.addFlowStart(Long.valueOf(prjLnkCompId));
            BaseLogUtils.newWebLogger("发起挂靠公司流程成功").setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setKeys("resultVO", JSON.toJSONString(resultVO))
                    .info();
        } catch (BaseException ex) {
            resultVO = new DataResultVO();
            resultVO.setSuccess(BaseConstant.IS_YESNO_NO);
            resultVO.setInfo(ex.getMessage());
            BaseLogUtils.newWebLogger("发起挂靠公司流程失败,业务异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .warn(LogExceptionEnum.COMMON_CODE_0001);
        } catch (Exception ex) {
            resultVO = new DataResultVO();
            resultVO.setSuccess(BaseConstant.IS_YESNO_NO);
            resultVO.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR + ex.getMessage());
            BaseLogUtils.newWebLogger("发起挂靠公司流程失败,系统异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .error(LogExceptionEnum.COMMON_CODE_0099);
        }
        return resultVO;
    }

    /**
     * 重卡事业部挂靠公司信息发起流程
     */
    @RequestMapping(value = "/addZkFlowStart.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object addZkFlowStart(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        //DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_ADD_SUCC);
        String prjLnkCompId = request.getParameter("prjLnkCompId");
        DataResultVO resultVO = new DataResultVO(BaseConstant.IS_YESNO_YES);
        try {
            boolean checkBlack = this.prjLnkCompQueryApiService.checkLnkCompIsBlack(Long.valueOf(prjLnkCompId),CurrentThreadContext.getCurrentSysCd(),CurrentThreadContext.getCurrentOrgCd());
            if(checkBlack){
                resultVO.setInfo("当前挂靠公司存在黑名单，无法发起准入流程！");
                resultVO.setSuccess(BaseConstant.IS_YESNO_NO);
                return resultVO ;
            }
            resultVO = this.prjLnkCompService.addZkFlowStart(Long.valueOf(prjLnkCompId));
            BaseLogUtils.newWebLogger("发起挂靠公司流程成功").setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setKeys("resultVO", JSON.toJSONString(resultVO))
                    .info();
        } catch (BaseException ex) {
            resultVO = new DataResultVO();
            resultVO.setSuccess(BaseConstant.IS_YESNO_NO);
            resultVO.setInfo(ex.getMessage());
            BaseLogUtils.newWebLogger("发起挂靠公司流程失败,业务异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .warn(LogExceptionEnum.COMMON_CODE_0001);
        } catch (Exception ex) {
            resultVO = new DataResultVO();
            resultVO.setSuccess(BaseConstant.IS_YESNO_NO);
            resultVO.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR + ex.getMessage());
            BaseLogUtils.newWebLogger("发起挂靠公司流程失败,系统异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .error(LogExceptionEnum.COMMON_CODE_0099);
        }
        return resultVO;
    }


    /**
     * 到供应商流程跟踪页面
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "/toPrjLinkFlowPage.do", method = {RequestMethod.GET})
    public ModelAndView toPrjLinkFlowPage(HttpServletRequest request, HttpServletResponse response) {
        String linkId = request.getParameter("linkId");
        ModelAndView view = new ModelAndView("project/prjlnkcomp/prjlnkFlowList");
        view.addObject("linkId", linkId);
        BaseLogUtils.newWebLogger("跳转到项目流程跟踪页面").setLogOperType(LogOperEnum.REQ)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                .setWarning(false)
                .setKeys("linkId", linkId)
                .info();
        return view;
    }

    /**
     * 初始化项目流程跟踪列表
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "/initPrjlnFlowList.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object initPorjectFlowList(HttpServletRequest request, HttpServletResponse response) {
        String linkId = request.getParameter("linkId");//挂靠公司Id
        List<PrjLinkFlowSHVO> list = new ArrayList<PrjLinkFlowSHVO>();
        if (StringUtils.isNotEmpty(linkId)) {
            list = this.prjLnkCompService.searchPrjLinkFlowList(Long.valueOf(linkId));
            for (PrjLinkFlowSHVO projectFlowSHVO : list) {
                if (StringUtils.isEmpty(projectFlowSHVO.getGrpFlag())) {
                    projectFlowSHVO.setGrpFlag("-");
                }
            }
            Collections.sort(list, new Comparator<PrjLinkFlowSHVO>() {
                public int compare(PrjLinkFlowSHVO o1, PrjLinkFlowSHVO o2) {
                    if (o1.getGrpFlag().compareTo(o2.getGrpFlag()) != 0) {
                        return o1.getGrpFlag().compareTo(o2.getGrpFlag());
                    }
                    return o1.getBusTyp().compareTo(o2.getBusTyp());
                }
            });
        }
        ListPageVO<PrjLinkFlowSHVO> listPage = new ListPageVO<PrjLinkFlowSHVO>(list, list.size());
        return listPage;
    }


    //=========================================私有方法========================================

    /**
     * 通过姓名身份证号码验证信息是否正确
     * @param cstNm
     * @param certNo
     * @return
     * @throws BaseException
     */
    private void validateIdCard(String cstNm,String certNo) {
        //验证身份证号格式
        this.checkVIDInfoItem(cstNm,certNo);
        //调用第三方接口验证证件信息
        this.validCert(cstNm, certNo, "身份证信息验证未通过!", "validateIdCard");
    }

    /**
     * 检查主要人员重要信息项
     * @param cstNm 姓名
     * @param certNo 证件号码
     */
    private void checkVIDInfoItem(String cstNm,String certNo) {
        String certTypCd = DictionaryConstant.CODE_CERT_TYP_CD_0;

        // 验证必填项及长度
        if (StringUtils.isBlank(cstNm) || cstNm.length() > 20 || !StringUtils.isCustomerName(cstNm)) {
            throw new BaseException(BaseExceptionConstant.COMMON_0001, "【"+certNo+"】"+PrjLnkCompRelInfoConstant.LOG_VALID_NM);
        }

        if (StringUtils.isBlank(certNo)) {
            throw new BaseException(BaseExceptionConstant.COMMON_0001,"【"+cstNm+"】"+ PrjLnkCompRelInfoConstant.LOG_VALID_CERT_NO_EMPTY);
        }

        if (certTypCd.equals(DictionaryConstant.CODE_CERT_TYP_CD_0) && !StringUtils.isIdCardNumber(certNo)) {
            throw new BaseException(BaseExceptionConstant.COMMON_0001, "【"+cstNm+"】"+ PrjLnkCompRelInfoConstant.LOG_VALID_CERT_NO_ERROR);
        }
    }



    /**
     * 证件验证
     *
     * @param certNm    证件名称
     * @param certNo    证件号码
     * @param errorDesc 错误信息
     * @Param funName
     */
    private CstValidCardInfoVO validCert(String certNm, String certNo, String errorDesc, String funName) {
        CstValidCardInfoVO cstValidCardInfoVO = this.cstBscInfoService.validateCstCert(certNm, certNo);
        if (!cstValidCardInfoVO.getSuccess()) {
            //第三方验证未通过
            BaseLogUtils.newWebLogger(errorDesc).setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setKeys("certNm", certNm)
                    .setKeys("certNo", certNo)
                    .warn(LogExceptionEnum.COMMON_CODE_0002);
            throw new BaseException(BaseExceptionConstant.COMMON_0001, errorDesc);
        }
        return cstValidCardInfoVO;
    }

    private PrjLnkCompVO getPrjLnkCompParam(HttpServletRequest request) {
        BaseLogUtils.newWebLogger("获取挂靠公司数据详情，请求参数").setLogOperType(LogOperEnum.REQ)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                .setWarning(false)
                .setKeys("request", super.getRequestParameter(request))
                .info();
		PrjLnkCompVO prjLnkCompVO = new PrjLnkCompVO();
		String lnkCompNm = request.getParameter("lnkCompNm");//挂靠公司名称
		String ownerCd = request.getParameter("ownerCd");// 挂靠公司归属
		String officeAddr = request.getParameter("officeAddr");//所在地
		String majorBiz = request.getParameter("majorBiz");//主营项目类别
		String succ = request.getParameter("succ");// 社会统一信用代码
		String bizLicNo = request.getParameter("bizLicNo");//营业执照注册号
		String compTyp = request.getParameter("compTyp");//企业类型
		String regAddr = request.getParameter("regAddr");//注册地址
		String regDt = request.getParameter("regDt");//成立日期
		String taxRegNo = request.getParameter("taxRegNo");//税务登记号
		String orgCode = request.getParameter("orgCode");//组织机构代码
		String expDt = request.getParameter("expDt");//道路运输许可证有效期
		String bizScope = request.getParameter("bizScope");//经营范围
		String corpRep = request.getParameter("corpRep");//法人代表
		String idNo = request.getParameter("idNo");//法人身份证号
		String totLnkQty = request.getParameter("totLnkQty");//自有车辆备案数量
		String ownQty = request.getParameter("ownQty");//自有车辆备案数量
		String ourTotLnkQyt = request.getParameter("ourTotLnkQyt");//在我司累积挂靠车辆
		String rem = request.getParameter("rem");//备注
		String lnkMp = request.getParameter("lnkMp");//联系人手机号码
		String lnkNm = request.getParameter("lnkNm");//联系人
		String lnkPost = request.getParameter("lnkPost");//联系人职务
		String fileParams = request.getParameter("fileParams");
		String actCtrlNm = request.getParameter("actCtrlNm");//实际控制人
		String actCtrlMp = request.getParameter("actCtrlMp");//实际联系人电话
		String rlPsnList = request.getParameter("rlPsnList");
		String rgnPrCd = request.getParameter("rgnPrCd");
		String rgnCyCd = request.getParameter("rgnCyCd");
		String importDataSource = request.getParameter("importDataSource");//数据来源
        String suppLnkPrjTypCd = request.getParameter("suppLnkPrjTypCd");//可支持挂靠项目类型
        String isUploadLoa = request.getParameter("isUploadLoa");//三方授权书是否上传
        String isRecycleLoa = request.getParameter("isRecycleLoa");//三方授权书是否回收

        try {
			List<PrjLnkCompRlPsnVO> list = new ArrayList<PrjLnkCompRlPsnVO>();
			if (StringUtils.isNotBlank(rlPsnList)) {
			    list = JSON.parseArray(rlPsnList, PrjLnkCompRlPsnVO.class);
			    for (PrjLnkCompRlPsnVO prjLnkCompRlPsnVO : list) {
			    	prjLnkCompRlPsnVO.setBusInfoVerify("2");
			    	prjLnkCompRlPsnVO.setPyPerVerify("2");
			    	prjLnkCompRlPsnVO.setTdPerVerify("2");
			    	prjLnkCompRlPsnVO.setBrPerVerify("2");
				}
			    String buOrgCd = CurrentThreadContext.getCurrentBuOrgCd();

			    for (PrjLnkCompRlPsnVO prjLnkCompRlPsnVO : list) {
			    	if(!buOrgCd.equals(PrjBscInfoConstant.CODE_BU_ORG_CD_XNY)){
				        //验证主要联系人信息是否输入
				        if (StringUtils.isBlank(prjLnkCompRlPsnVO.getRlNm())) {
				            throw new BaseException(BaseExceptionConstant.COMMON_0001, "主要人员名称不能为空！");
				        }
				        // 验证必填项及长度
				        if (StringUtils.isBlank(prjLnkCompRlPsnVO.getRlNm()) || prjLnkCompRlPsnVO.getRlNm().length() > 20 || !StringUtils.isCustomerName(prjLnkCompRlPsnVO.getRlNm())) {
				            throw new BaseException(BaseExceptionConstant.COMMON_0001, "【"+ prjLnkCompRlPsnVO.getRlTypCdNm() +"】"+PrjLnkCompRelInfoConstant.LOG_VALID_NM);
				        }
				        if (StringUtils.isBlank(prjLnkCompRlPsnVO.getRlTypCd())) {
				            throw new BaseException(BaseExceptionConstant.COMMON_0001, "主要人员联系人类型不能为空！");
				        }
						/*if (StringUtils.isBlank(prjLnkCompRlPsnVO.getCertTypCd())
								&& StringUtils.isNotEmpty(prjLnkCompRlPsnVO.getIsDefault())
								&& 1 == prjLnkCompRlPsnVO.getIsDefault()) {
							throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "【"+ prjLnkCompRlPsnVO.getRlTypCdNm() +"】证件类型不能为空！");
						}*/
                        if (StringUtils.isBlank(prjLnkCompRlPsnVO.getCertTypCd())) {
                            throw new BaseException(BaseExceptionConstant.COMMON_0001, "【"+ prjLnkCompRlPsnVO.getRlTypCdNm() +"】证件类型不能为空！");
                        }
						/*if (StringUtils.isBlank(prjLnkCompRlPsnVO.getCertNo())
								&& StringUtils.isNotEmpty(prjLnkCompRlPsnVO.getIsDefault())
								&& 1 == prjLnkCompRlPsnVO.getIsDefault()) {
							throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "【"+ prjLnkCompRlPsnVO.getRlTypCdNm() +"】证件号不能为空！");
						}*/
                        if (StringUtils.isBlank(prjLnkCompRlPsnVO.getCertNo())
                                && StringUtils.isNotEmpty(prjLnkCompRlPsnVO.getRlTypCd())
                                && "2".equals(prjLnkCompRlPsnVO.getRlTypCd())) {
                            throw new BaseException(BaseExceptionConstant.COMMON_0001, "【"+ prjLnkCompRlPsnVO.getRlTypCdNm() +"】证件号不能为空！");
                        }
						/*if (StringUtils.isNotEmpty(prjLnkCompRlPsnVO.getIsDefault())
								&& 1 == prjLnkCompRlPsnVO.getIsDefault()) {
							if (prjLnkCompRlPsnVO.getCertTypCd().equals(PrjLnkCompRelInfoConstant.CODE_CERT_TYP_DEF_CD)) {
								if (!StringUtils.isIdCardNumber(prjLnkCompRlPsnVO.getCertNo())) {
									throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604,
											"【"+ prjLnkCompRlPsnVO.getRlTypCdNm() +"】身份证号格式不正确");
								}
							}
						}*/
                        if (prjLnkCompRlPsnVO.getCertTypCd().equals(PrjLnkCompRelInfoConstant.CODE_CERT_TYP_DEF_CD)
                            && StringUtils.isNotBlank(prjLnkCompRlPsnVO.getCertNo())) {
                            if (!StringUtils.isIdCardNumber(prjLnkCompRlPsnVO.getCertNo())) {
                                throw new BaseException(BaseExceptionConstant.COMMON_0001,
                                        "【"+ prjLnkCompRlPsnVO.getRlTypCdNm() +"】身份证号格式不正确");
                            }
                        }
						/*if (StringUtils.isBlank(prjLnkCompRlPsnVO.getTel())
								&& StringUtils.isNotEmpty(prjLnkCompRlPsnVO.getIsDefault())
								&& 1 == prjLnkCompRlPsnVO.getIsDefault()) {
							throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "主要人员联系电话不能为空！");
						}*/
                        if (StringUtils.isBlank(prjLnkCompRlPsnVO.getTel())
                                && StringUtils.isNotEmpty(prjLnkCompRlPsnVO.getRlTypCd())
                                && "2".equals(prjLnkCompRlPsnVO.getRlTypCd())) {
                            throw new BaseException(BaseExceptionConstant.COMMON_0001, "主要人员联系电话不能为空！");
                        }
						/*if (StringUtils.isNotEmpty(prjLnkCompRlPsnVO.getIsDefault())
								&& 1 == prjLnkCompRlPsnVO.getIsDefault()) {
							if (!StringUtils.checkMobileNumber(prjLnkCompRlPsnVO.getTel())) {
								throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604,
										"主要人员联系电话格式不正确");
							}
						}*/
						if (StringUtils.isNotEmpty(prjLnkCompRlPsnVO.getRlTypCd())
                                && StringUtils.isNotBlank(prjLnkCompRlPsnVO.getTel())) {
							if (!StringUtils.checkMobileNumber(prjLnkCompRlPsnVO.getTel())) {
								throw new BaseException(BaseExceptionConstant.COMMON_0001,
										"主要人员联系电话格式不正确");
							}
						}
						//验证身份证号码的有效性
						/*if (StringUtils.isNotEmpty(prjLnkCompRlPsnVO.getIsDefault()) && 1 == prjLnkCompRlPsnVO.getIsDefault()) {
							if(DictionaryConstant.CODE_CERT_TYP_CD_0.equals(prjLnkCompRlPsnVO.getCertTypCd())){
								this.validateIdCard(prjLnkCompRlPsnVO.getRlNm(),prjLnkCompRlPsnVO.getCertNo());
							}
						}*/
                        if(DictionaryConstant.CODE_CERT_TYP_CD_0.equals(prjLnkCompRlPsnVO.getCertTypCd())
                                && "2".equals(prjLnkCompRlPsnVO.getRlTypCd())) {
                            this.validateIdCard(prjLnkCompRlPsnVO.getRlNm(),prjLnkCompRlPsnVO.getCertNo());
                        }
			    	}
			    	
					
					if(buOrgCd.equals(PrjBscInfoConstant.CODE_BU_ORG_CD_XNY)){
			     	     if (prjLnkCompRlPsnVO.getCertTypCd().equals(PrjLnkCompRelInfoConstant.CODE_CERT_TYP_DEF_CD)&&StringUtils.isNotBlank(prjLnkCompRlPsnVO.getCertNo())) {
			                 if (!StringUtils.isIdCardNumber(prjLnkCompRlPsnVO.getCertNo())) {
			                     throw new BaseException(BaseExceptionConstant.COMMON_0001, "身份证号格式不正确");
			                 }
			             	this.validateIdCard(prjLnkCompRlPsnVO.getRlNm(),prjLnkCompRlPsnVO.getCertNo());
			             }
			     		if(StringUtils.isNotBlank(prjLnkCompRlPsnVO.getTel())){
			     			if (!StringUtils.checkMobileNumber(prjLnkCompRlPsnVO.getTel())) {
			     				throw new BaseException(BaseExceptionConstant.COMMON_0001, "主要人员联系电话格式不正确");
			     			}
			     		}
			     	     
			     	}
			    }
			    if (!buOrgCd.equals(PrjBscInfoConstant.CODE_BU_ORG_CD_XNY)) {
					//验证必填联系人是否填写start
					//联系人类型
					Map<String, SysDictionaryDTO> lnkCompRLTypCdMap = this.sysDictionaryApiService.searchGroupToObjMap(
							CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(),
							DictionaryConstant.CODE__PRJ_LNK_COMP_RL_PSN_TYP_CD);
					//必须维护联系人类型
					List<String> mustRlTypCdList = new ArrayList<String>();
					for (Entry<String, SysDictionaryDTO> entry : lnkCompRLTypCdMap.entrySet()) {
						if (BaseConstant.IS_YESNO_YES == entry.getValue().getIsSysDef()) {
							mustRlTypCdList.add(entry.getKey());
						}
					}
					//前端传回的联系人类型集合
					List<String> rlTypCdList = new ArrayList<String>();
					for (PrjLnkCompRlPsnVO lnkCompRlPsnVO : list) {
						if (null != lnkCompRlPsnVO) {
							rlTypCdList.add(lnkCompRlPsnVO.getRlTypCd());
						}
					}
					for (String string : mustRlTypCdList) {
						if (!rlTypCdList.contains(string)) {
							throw new BaseException(BaseExceptionConstant.COMMON_0001,
									"请维护" + lnkCompRLTypCdMap.get(string).getCodeNm() + "信息。");
						}
					}
					//验证必填联系人是否填写end
				}
			}
			Date regDate = null;
			if (StringUtils.isNotBlank(regDt)) {
			    regDate = DateUtils.formatStringToDate(regDt, DateUtils.YYYY_MM_DD);
			    if (DateUtils.after(new Date(), regDate)) {
			        throw new BaseException(BaseExceptionConstant.COMMON_0001, "成立日期应在当前日期之前");
			    }
			} else {
			    throw new BaseException("成立日期不能为空!");
            }

			if (StringUtils.isNotBlank(totLnkQty)) {
			    if (!StringUtils.isUnsignedNumeric(totLnkQty)) {
			        throw new BaseException(BaseExceptionConstant.COMMON_0001, "现累计挂靠数量应为数字");
			    }
			}
			if (StringUtils.isNotBlank(ownQty)) {
			    if (!StringUtils.isUnsignedNumeric(ownQty)) {
			        throw new BaseException(BaseExceptionConstant.COMMON_0001, "自有车辆备案数量应为数字");
			    }
			}
            Date expDate = DateUtils.formatStringToDate(expDt, DateUtils.YYYY_MM_DD);
            //String buOrgCd = CurrentThreadContext.getCurrentBuOrgCd();
//			if (StringUtils.isNotBlank(expDt)) {
//			    if (DateUtils.before(new Date(), expDate)) {
//			        throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604, "道路运输许可证有效期应在当前日期之后");
//			    }
//			}

			if (StringUtils.isBlank(lnkCompNm)) {
			    throw new BaseException(BaseExceptionConstant.COMMON_0001, " 挂靠公司名称不能为空");
			}

			String isApplyPage = request.getParameter("isApplyPage");
			if (StringUtils.isEmpty(isApplyPage) || !"1".equals(isApplyPage)) {
				if (StringUtils.isBlank(succ)) {
					throw new BaseException(BaseExceptionConstant.COMMON_0001, "统一社会信用代码不能为空");
				} else {
					PrjLnkCompQueryCondition condition = new PrjLnkCompQueryCondition();
					condition.setSucc(succ);
					List<PrjLnkCompVO> prjLnkCompList = this.prjLnkCompService.getPrjLnkCompByCondition(condition);
                    if (CollectionUtils.isNotEmpty(prjLnkCompList) && prjLnkCompList.size() > 1) {
                        throw new BaseException(BaseExceptionConstant.COMMON_0001, "社会统一信用代码号已存在.");
						/*String lnkCompId = request.getParameter("lnkCompId");
						if (StringUtils.isEmpty(lnkCompId)) {//新增
							throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "社会统一信用代码号已存在.");
						} else {//修改
							if (!lnkCompId.equals(prjLnkCompList.get(0).getId().toString())) {
								throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "社会统一信用代码号已存在.");
							}
						}*/
					}
				} 
			}

            if (StringUtils.isEmpty(ownerCd)) {
                throw new BaseException("公司归属不能为空!");
            }

            if (StringUtils.isEmpty(officeAddr)) {
                throw new BaseException("挂靠公司所在地不能为空!");
            }

            /*if (StringUtils.isEmpty(majorBiz)) {
                throw new BaseException("主营项目类别不能为空!");
            }*/

            if (StringUtils.isEmpty(regAddr)) {
                throw new BaseException("注册地址不能为空!");
            }

            /*if (StringUtils.isEmpty(bizScope)) {
                throw new BaseException("经营范围不能为空!");
            }*/

            if (StringUtils.isNotEmpty(suppLnkPrjTypCd)) {
                String[] split = suppLnkPrjTypCd.split(";");
                List<String> suppLnkPrjTypCdList = new ArrayList<>(split.length);
                for (String s : split) {
                    suppLnkPrjTypCdList.add(s);
                }
                prjLnkCompVO.setSuppPrjTypCdList(suppLnkPrjTypCdList);
            }

			//解析附件上传信息
			if (StringUtils.isNotBlank(fileParams)) {
                List<PrjFileInfoVO> fileParamList = JSON.parseArray(fileParams, PrjFileInfoVO.class);
                if(CollectionUtils.isNotEmpty(fileParamList)){
                    List<SysUlFilesRecVO> fileList = new ArrayList<>(fileParamList.size());
                    SysUlFilesRecVO filesRecVO ;
                    for (PrjFileInfoVO fileInfoVO : fileParamList) {
                        filesRecVO = new SysUlFilesRecVO();
                        if (StringUtils.isNotEmpty(fileInfoVO.getFileId())) {
                            filesRecVO.setId(fileInfoVO.getFileId());
                        }
                        filesRecVO.setFilePath(fileInfoVO.getFilePath());
                        filesRecVO.setFileNm(fileInfoVO.getFileNm());
                        if (StringUtils.isEmpty(ownerCd)) {
                            filesRecVO.setCfgCd(LnkCompFileCfgEnum.PRJ029.getCode());
                            filesRecVO.setTabNm(LnkCompFileCfgEnum.PRJ029.getTableNm());
                            filesRecVO.setSysCd(LnkCompFileCfgEnum.PRJ029.getSysCd());
                        } else {
                            if ("1".equals(ownerCd)) {
                                filesRecVO.setCfgCd(LnkCompFileCfgEnum.PRJ030.getCode());
                                filesRecVO.setTabNm(LnkCompFileCfgEnum.PRJ030.getTableNm());
                                filesRecVO.setSysCd(LnkCompFileCfgEnum.PRJ030.getSysCd());
                            } else if ("2".equals(ownerCd)) {
                                filesRecVO.setCfgCd(LnkCompFileCfgEnum.PRJ029.getCode());
                                filesRecVO.setTabNm(LnkCompFileCfgEnum.PRJ029.getTableNm());
                                filesRecVO.setSysCd(LnkCompFileCfgEnum.PRJ029.getSysCd());
                            } else {
                                filesRecVO.setCfgCd(LnkCompFileCfgEnum.PRJ032.getCode());
                                filesRecVO.setTabNm(LnkCompFileCfgEnum.PRJ032.getTableNm());
                                filesRecVO.setSysCd(LnkCompFileCfgEnum.PRJ032.getSysCd());
                            }
                        }
                        /*if (StringUtils.isEmpty(ownerCd) || !"1".equals(ownerCd)) {// 挂靠公司默认归属第三方
                            filesRecVO.setCfgCd(LnkCompFileCfgEnum.PRJ029.getCode());
                        } else {
                            filesRecVO.setCfgCd(LnkCompFileCfgEnum.PRJ030.getCode());
                        }*/
                        filesRecVO.setCfgDtlCd(fileInfoVO.getCfgDtlCd());
                        filesRecVO.setOrgCd(fileInfoVO.getOrgCd());
                        /*if (StringUtils.isEmpty(ownerCd) || !"1".equals(ownerCd)) {// 挂靠公司默认归属第三方
                            filesRecVO.setTabNm(LnkCompFileCfgEnum.PRJ029.getTableNm());
                            filesRecVO.setSysCd(LnkCompFileCfgEnum.PRJ029.getSysCd());
                        } else {
                            filesRecVO.setTabNm(LnkCompFileCfgEnum.PRJ030.getTableNm());
                            filesRecVO.setSysCd(LnkCompFileCfgEnum.PRJ030.getSysCd());
                        }*/
                        fileList.add(filesRecVO);
                    }
                    prjLnkCompVO.setFileList(fileList);
                }
			}

			prjLnkCompVO.setRlPsnList(list);
			prjLnkCompVO.setActCtrlMp(actCtrlMp);
			prjLnkCompVO.setActCtrlNm(actCtrlNm);
			prjLnkCompVO.setLnkCompNm(lnkCompNm);
			prjLnkCompVO.setOwnerCd(ownerCd);
			prjLnkCompVO.setOfficeAddr(officeAddr);
			prjLnkCompVO.setMajorBiz(majorBiz);
			prjLnkCompVO.setSucc(succ);
			//if (StringUtils.isNotEmpty(bizLicNo)) {
			//	prjLnkCompVO.setBizLicNo(bizLicNo);
			//} else {
				prjLnkCompVO.setBizLicNo(succ);
			//}
			prjLnkCompVO.setCompTyp(compTyp);
			prjLnkCompVO.setRegAddr(regAddr);
			prjLnkCompVO.setRegDt(regDate);
			///if (StringUtils.isNotEmpty(taxRegNo)) {
			//	prjLnkCompVO.setTaxRegNo(taxRegNo);
			//} else {
				prjLnkCompVO.setTaxRegNo(succ);
			//}
			//if (StringUtils.isNotEmpty(orgCode)) {
			//	prjLnkCompVO.setOrgCode(orgCode);
			//} else {
				prjLnkCompVO.setOrgCode(succ);
			//}
			//prjLnkCompVO.setCreditcode(creditcode);
			prjLnkCompVO.setExpDt(expDate);
			prjLnkCompVO.setBizScope(bizScope);
			prjLnkCompVO.setCorpRep(corpRep);
			prjLnkCompVO.setIdNo(idNo);
			prjLnkCompVO.setOwnQty(ownQty);
			prjLnkCompVO.setRgnPrCd(rgnPrCd);
			prjLnkCompVO.setRgnCyCd(rgnCyCd);
			if (StringUtils.isNotBlank(ourTotLnkQyt)) {
			    prjLnkCompVO.setOurTotLnkQyt(Integer.parseInt(ourTotLnkQyt));
			}
			prjLnkCompVO.setRem(rem);
			prjLnkCompVO.setLnkMp(lnkMp);
			prjLnkCompVO.setLnkNm(lnkNm);
			prjLnkCompVO.setLnkPost(lnkPost);
			prjLnkCompVO.setTotLnkQty(totLnkQty);
			prjLnkCompVO.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
			prjLnkCompVO.setMdfTm(new Date());
			prjLnkCompVO.setImportDataSource(importDataSource);//数据来源
			//prjLnkCompVO.setOrgCode(orgCode);
			if(StringUtils.isNotEmpty(isUploadLoa)){
				prjLnkCompVO.setIsUploadLoa(Integer.valueOf(isUploadLoa));
			}
			if(StringUtils.isNotEmpty(isRecycleLoa)){
				prjLnkCompVO.setIsRecycleLoa(Integer.valueOf(isRecycleLoa));
			}
            BaseLogUtils.newWebLogger("获取挂靠公司数据详情").setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setKeys("prjLnkCompVO", JSON.toJSONString(prjLnkCompVO))
                    .info();
			return prjLnkCompVO;
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			throw e;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			throw e;
		}
	}

    @RequestMapping(value = "/updateBlackList",method = RequestMethod.POST)
    @ResponseBody
    public DataResultVO updateBlackList(String id,String blackList, String reason){
        DataResultVO dataResultVO = new DataResultVO();
        if(StringUtils.isBlank(id) || StringUtils.isBlank(blackList)){
            dataResultVO.setSuccess(0);
            // 这是不对的！  error
        }else{
            dataResultVO.setSuccess(1);
            try{
                if (StringUtils.isNotEmpty(reason)) {
                    if("1".equals(blackList)){
                        // 插入供应商操作记
                        Long add = this.splOpLogRecService.add(id, reason, SplRelLogOpTypCdNum.ADDBLACK.getOpTypCd(), SplRelLogBizTypCdNum.LNK.getBizTypCd());
                        dataResultVO.setInfo("已加入黑名单");
                    }else{
                        // 插入供应商操作记录
                        Long add = this.splOpLogRecService.add(id, reason, SplRelLogOpTypCdNum.CANCELBLACK.getOpTypCd(), SplRelLogBizTypCdNum.LNK.getBizTypCd());
                        dataResultVO.setInfo("已移除黑名单");
                    }
                }
                // DO UPDATE
                this.prjLnkCompService.updateBlackList(id,blackList);
            }catch (BaseException ex) {
                BaseLogUtils.newWebLogger("插入挂靠公司操作日志失败,业务异常").setLogOperType(LogOperEnum.REQ)
                        .setSysCd(CurrentThreadContext.getCurrentSysCd())
                        .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                        .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                        .setWarning(false)
                        .setThrowable(ex)
                        .warn(LogExceptionEnum.COMMON_CODE_0001);
            } catch (Exception ex) {
                BaseLogUtils.newWebLogger("插入挂靠公司操作日志失败,系统异常").setLogOperType(LogOperEnum.REQ)
                        .setSysCd(CurrentThreadContext.getCurrentSysCd())
                        .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                        .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                        .setWarning(false)
                        .setThrowable(ex)
                        .error(LogExceptionEnum.COMMON_CODE_0099);
            }

        }
        return dataResultVO;
    }

    /**
     * 初始化经销商变更资料列表
     */
    @RequestMapping(value = "/initLnkFileInfoList.do", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public Object initLnkFileInfoList(HttpServletRequest request, HttpServletResponse response) {
        String pkId = request.getParameter("pkId");//客户ID
        String cfgCd = request.getParameter("cfgCd");//附件配置编号
        String tabNm = request.getParameter("tabNm");//附件对应表名
        String cfgOrgCd = request.getParameter("cfgOrgCd") ;
        String cfgSysCd = request.getParameter("cfgSysCd") ;
        String uploadSysCd = request.getParameter("uploadSysCd") ;
        String applyId = request.getParameter("applyId");
        SysUlFilesRecQueryCondition qc = new SysUlFilesRecQueryCondition();
        qc.setPkId(pkId);
        if (StringUtils.isEmpty(applyId)) {
            qc.setCfgCd(cfgCd);
        } else {
            LnkCompModDtlQC modDtlQC = new LnkCompModDtlQC();
            modDtlQC.setModId(Long.valueOf(applyId));
            modDtlQC.setModAttrFiled("ownerCd");
            modDtlQC.setIsDel(BaseConstant.IS_YESNO_NO);
            List<LnkCompModDtlDTO> ownerCdModDtlList = this.lnkCompModDtlApiService.searchList(modDtlQC);
            if (CollectionUtils.isEmpty(ownerCdModDtlList)) {
                qc.setCfgCd(cfgCd);
            } else {
                LnkCompModDtlDTO lnkCompModDtlDTO = ownerCdModDtlList.get(0);
                if ("1".equals(lnkCompModDtlDTO.getModConBef())) {
                    qc.setCfgCd(LnkCompFileCfgEnum.PRJ030.getCode());
                } else if ("2".equals(lnkCompModDtlDTO.getModConBef())) {
                    qc.setCfgCd(LnkCompFileCfgEnum.PRJ029.getCode());
                } else {
                    qc.setCfgCd(LnkCompFileCfgEnum.PRJ032.getCode());
                }
            }
        }
        if(StringUtils.isNotEmpty(cfgSysCd)){
            qc.setSysCd(cfgSysCd);
        }else{
            qc.setSysCd(SplSystemConstant.SPL_SYS_CD);
        }
        if(StringUtils.isNotEmpty(cfgOrgCd)){
            qc.setOrgCd(cfgOrgCd);
        }else{
            qc.setOrgCd(SplSystemConstant.DEFAULT_ORG_CD);
        }
        if(StringUtils.isNotEmpty(tabNm)){
            qc.setTabNm(tabNm);
        }
        qc.setIsDel(BaseConstant.IS_YESNO_NO);
        List<PrjFileInfoVO> list = this.getUploadFileList(qc, applyId);
        ListPageVO listPageVO = null ;
        if (CollectionUtils.isNotEmpty(list)) {
            listPageVO =  new ListPageVO<PrjFileInfoVO>(list, list.size());
        }else{
            listPageVO =  new ListPageVO<PrjFileInfoVO>(new ArrayList<PrjFileInfoVO>(), 0);
        }
        BaseLogUtils.newWebLogger("初始化经销商变更资料列表").setLogOperType(LogOperEnum.RESP)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                .setWarning(false)
                .setKeys("listPageVO", JSON.toJSONString(listPageVO))
                .info();
        return listPageVO ;
    }

    /**
     * 初始化经销商变更资料列表
     */
    @RequestMapping(value = "/initPropFileList.do", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public Object initPropFileList(HttpServletRequest request, HttpServletResponse response) {
        String pkId = request.getParameter("pkId");//客户ID
        String cfgCd = request.getParameter("cfgCd");//附件配置编号
        String tabNm = request.getParameter("tabNm");//附件对应表名
        String cfgOrgCd = request.getParameter("cfgOrgCd") ;
        String cfgSysCd = request.getParameter("cfgSysCd") ;
        String uploadSysCd = request.getParameter("uploadSysCd") ;
        String applyId = request.getParameter("applyId");
        ListPageVO listPageVO = null ;
        SysUlFilesRecQueryCondition qc = new SysUlFilesRecQueryCondition();
        qc.setPkId(pkId);
        if (StringUtils.isNotEmpty(cfgCd)) {
            qc.setCfgCd(cfgCd);
        }
        if(StringUtils.isNotEmpty(cfgSysCd)){
            qc.setSysCd(cfgSysCd);
        }else{
            qc.setSysCd(SplSystemConstant.SPL_SYS_CD);
        }
        if(StringUtils.isNotEmpty(cfgOrgCd)){
            qc.setOrgCd(cfgOrgCd);
        }else{
            qc.setOrgCd(SplSystemConstant.DEFAULT_ORG_CD);
        }
        if(StringUtils.isNotEmpty(tabNm)){
            qc.setTabNm(tabNm);
        }
        qc.setIsDel(BaseConstant.IS_YESNO_NO);
        List<PrjFileInfoVO> list = new ArrayList<>();
        List<PrjFileInfoVO> list1 = this.getPropUploadFileList(qc);
        if(CollectionUtils.isNotEmpty(list1)) {
            list.addAll(list1);
        }
        if(StringUtils.isNotEmpty(applyId)){
            List<PrjFileInfoVO> newList = new ArrayList<>();;
            qc.setPkId(applyId);
            List<PrjFileInfoVO> list2 = this.getPropUploadFileList(qc);
            if(CollectionUtils.isNotEmpty(list2)) {
                list.addAll(list2);
            }
            LnkCompModDtlQC lnkCompModDtlQC = new LnkCompModDtlQC();
            lnkCompModDtlQC.setModId(Long.valueOf(applyId));
            lnkCompModDtlQC.setIsDel(BaseConstant.IS_YESNO_NO);
            lnkCompModDtlQC.setIsValid(BaseConstant.IS_YESNO_YES);
            lnkCompModDtlQC.setTabNm("SYS_UL_FILES_REC");
            List<LnkCompModDtlDTO> modDtlDTOList = this.lnkCompModDtlApiService.searchList(lnkCompModDtlQC);
            List<Long> delIds = new ArrayList<>();
            if(CollectionUtils.isNotEmpty(modDtlDTOList)){
                for (LnkCompModDtlDTO modDtlDTO:modDtlDTOList) {
                    if("DEL".equals(modDtlDTO.getModTypCd())){
                        delIds.add(Long.valueOf(modDtlDTO.getModConAft()));
                    }
                }
            }
            for (PrjFileInfoVO fileInfoVO: list) {
                if(!delIds.contains(fileInfoVO.getFileId())){
                    newList.add(fileInfoVO);
                }
            }
            listPageVO =  new ListPageVO<PrjFileInfoVO>(newList, newList.size());
            return listPageVO ;
        }

        if (CollectionUtils.isNotEmpty(list)) {
            listPageVO =  new ListPageVO<PrjFileInfoVO>(list, list.size());
        }else{
            listPageVO =  new ListPageVO<PrjFileInfoVO>(new ArrayList<PrjFileInfoVO>(), 0);
        }
        BaseLogUtils.newWebLogger("初始化经销商变更资料列表").setLogOperType(LogOperEnum.RESP)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                .setWarning(false)
                .setKeys("listPageVO", JSON.toJSONString(listPageVO))
                .info();
        return listPageVO ;
    }


    /**
     * @param condition 包含配置文件的系统CDOE
     * @return
     * @throws BaseException
     */
    private List<PrjFileInfoVO> getUploadFileList(SysUlFilesRecQueryCondition condition, String applyId) throws BaseException {
        //查询资料配置，系统代码,组织架构代码,配置编号 ,业务主键
        SysUlDatCfgQueryCondition ulDatCfgQueryCondition = new SysUlDatCfgQueryCondition();
        ulDatCfgQueryCondition.setSysCd(condition.getSysCd());//系统代码
        ulDatCfgQueryCondition.setOrgCd(condition.getOrgCd());
        ulDatCfgQueryCondition.setDataId(String.valueOf(condition.getPkId()));//业务主键
        ulDatCfgQueryCondition.setIsValid(BaseConstant.IS_YESNO_YES);
        ulDatCfgQueryCondition.setIsDel(BaseConstant.IS_YESNO_NO);
        List<String> cfgCdList = new ArrayList<>();
        cfgCdList.add(condition.getCfgCd());//配置编号
        ulDatCfgQueryCondition.setCfgCdList(cfgCdList);//配置编号集合
        List<SysUlDatCfgDTO> list = null ;
        List<PrjFileInfoVO> voList = null;
        if(StringUtils.isEmpty(condition.getPkId())){
            list =this.uploadApiService.searchSysUlDatCfgList(ulDatCfgQueryCondition);
        }else{
            list = this.uploadApiService.searchSysUlDatCfgListByDataId(ulDatCfgQueryCondition);
        }
        if (StringUtils.isNotEmpty(applyId)) {
            //变更删除的文件
            LnkCompModDtlQC modDtlQC = new LnkCompModDtlQC();
            modDtlQC.setModId(Long.valueOf(applyId));
            modDtlQC.setModAttrFiled("id");
            modDtlQC.setTabNm(LnkCompConstant.LNK_COMP_FILE_REC_TAB);
            modDtlQC.setModTypCd("DEL");
            modDtlQC.setIsDel(BaseConstant.IS_YESNO_NO);
            List<LnkCompModDtlDTO> deleteFilesIdModDtlList = this.lnkCompModDtlApiService.searchList(modDtlQC);
            List<Long> deleteFilesIdList = null;
            if (CollectionUtils.isNotEmpty(deleteFilesIdModDtlList)) {
                deleteFilesIdList = new ArrayList<>();
                for (LnkCompModDtlDTO dtlDTO : deleteFilesIdModDtlList) {
                    if (StringUtils.isNotEmpty(dtlDTO.getModConAft())) {
                        deleteFilesIdList.add(Long.valueOf(dtlDTO.getModConAft()));
                    }
                }
            }

            //List<String> hasFileCfgDtlCdList = new ArrayList<>();
            //变更前文件整合
            List<SysUlDatCfgDtlDTO> beforeApplyFileList = new ArrayList<>();
            for (SysUlDatCfgDTO dto : list) {
                //beforeApplyFileList.addAll(dto.getSysUlDatCfgDtlDTOList());
                for (SysUlDatCfgDtlDTO sysUlDatCfgDtlDTO : dto.getSysUlDatCfgDtlDTOList()) {
                    if (StringUtils.isNotEmpty(sysUlDatCfgDtlDTO.getRecId())) {
                        if (CollectionUtils.isNotEmpty(deleteFilesIdList) && deleteFilesIdList.contains(sysUlDatCfgDtlDTO.getRecId())) {
                            continue;
                        }
                        beforeApplyFileList.add(sysUlDatCfgDtlDTO);
                    }
                }
            }
            //Map<String, List<SysUlDatCfgDtlDTO>> beforeApplyFileMap = new HashMap<>();
            ArrayList<SysUlDatCfgDtlDTO> sysUlDatCfgDtlDTOS ;
            /*for (SysUlDatCfgDtlDTO sysUlDatCfgDtlDTO : beforeApplyFileList) {
                if (StringUtils.isNotEmpty(sysUlDatCfgDtlDTO.getRecId())) {
                    if (CollectionUtils.isNotEmpty(deleteFilesIdList) && deleteFilesIdList.contains(sysUlDatCfgDtlDTO.getRecId())) {
                        continue;
                    }
                    if (beforeApplyFileMap.containsKey(sysUlDatCfgDtlDTO.getCfgDtlCd())) {
                        beforeApplyFileMap.get(sysUlDatCfgDtlDTO.getCfgDtlCd()).add(sysUlDatCfgDtlDTO);
                    } else {
                        sysUlDatCfgDtlDTOS = new ArrayList<>();
                        sysUlDatCfgDtlDTOS.add(sysUlDatCfgDtlDTO);
                        beforeApplyFileMap.put(sysUlDatCfgDtlDTO.getCfgDtlCd(), sysUlDatCfgDtlDTOS);
                    }
                    hasFileCfgDtlCdList.add(sysUlDatCfgDtlDTO.getCfgDtlCd());
                }
            }*/

            //变更文件整合
            ulDatCfgQueryCondition.setDataId(applyId);

            modDtlQC = new LnkCompModDtlQC();
            modDtlQC.setModId(Long.valueOf(applyId));
            modDtlQC.setModAttrFiled("ownerCd");
            modDtlQC.setIsDel(BaseConstant.IS_YESNO_NO);
            List<LnkCompModDtlDTO> ownerCdModDtlList = this.lnkCompModDtlApiService.searchList(modDtlQC);
            if (CollectionUtils.isNotEmpty(ownerCdModDtlList)) {
                LnkCompModDtlDTO lnkCompModDtlDTO = ownerCdModDtlList.get(0);

                cfgCdList = new ArrayList<>();
                if ("1".equals(lnkCompModDtlDTO.getModConAft())) {
                    cfgCdList.add(LnkCompFileCfgEnum.PRJ030.getCode());//配置编号
                } else if ("2".equals(lnkCompModDtlDTO.getModConAft())) {
                    cfgCdList.add(LnkCompFileCfgEnum.PRJ029.getCode());//配置编号
                } else {
                    cfgCdList.add(LnkCompFileCfgEnum.PRJ032.getCode());//配置编号
                }
                ulDatCfgQueryCondition.setCfgCdList(cfgCdList);//配置编号集合
            }

            List<SysUlDatCfgDTO> applyList = this.uploadApiService.searchSysUlDatCfgListByDataId(ulDatCfgQueryCondition);
            List<SysUlDatCfgDtlDTO> applyFileList = new ArrayList<>();
            for (SysUlDatCfgDTO dto : applyList) {
                //applyFileList.addAll(dto.getSysUlDatCfgDtlDTOList());
                for (SysUlDatCfgDtlDTO sysUlDatCfgDtlDTO : dto.getSysUlDatCfgDtlDTOList()) {
                    if (StringUtils.isNotEmpty(sysUlDatCfgDtlDTO.getRecId())) {
                        if (CollectionUtils.isNotEmpty(deleteFilesIdList) && deleteFilesIdList.contains(sysUlDatCfgDtlDTO.getRecId())) {
                            continue;
                        }
                        applyFileList.add(sysUlDatCfgDtlDTO);
                    }
                }
            }
            //Map<String, List<SysUlDatCfgDtlDTO>> applyFileMap = new HashMap<>();
            //ArrayList<SysUlDatCfgDtlDTO> sysUlDatCfgDtlDTOS ;
            /*for (SysUlDatCfgDtlDTO sysUlDatCfgDtlDTO : applyFileList) {
                if (StringUtils.isNotEmpty(sysUlDatCfgDtlDTO.getRecId())) {
                    if (applyFileMap.containsKey(sysUlDatCfgDtlDTO.getCfgDtlCd())) {
                        applyFileMap.get(sysUlDatCfgDtlDTO.getCfgDtlCd()).add(sysUlDatCfgDtlDTO);
                    } else {
                        sysUlDatCfgDtlDTOS = new ArrayList<>();
                        sysUlDatCfgDtlDTOS.add(sysUlDatCfgDtlDTO);
                        applyFileMap.put(sysUlDatCfgDtlDTO.getCfgDtlCd(), sysUlDatCfgDtlDTOS);
                    }
                    hasFileCfgDtlCdList.add(sysUlDatCfgDtlDTO.getCfgDtlCd());
                }
            }*/

            List<SysUlDatCfgDtlDTO> afterApplyFileList = new ArrayList<>();
            if (CollectionUtils.isNotEmpty(beforeApplyFileList)) {
                afterApplyFileList.addAll(beforeApplyFileList);
            }
            if (CollectionUtils.isNotEmpty(applyFileList)) {
                afterApplyFileList.addAll(applyFileList);
            }
            Map<String, List<SysUlDatCfgDtlDTO>> afterApplyFileMap = new HashMap<>();
            for (SysUlDatCfgDtlDTO sysUlDatCfgDtlDTO : afterApplyFileList) {
                if (afterApplyFileMap.containsKey(sysUlDatCfgDtlDTO.getCfgDtlCd())) {
                    afterApplyFileMap.get(sysUlDatCfgDtlDTO.getCfgDtlCd()).add(sysUlDatCfgDtlDTO);
                } else {
                    sysUlDatCfgDtlDTOS = new ArrayList<>();
                    sysUlDatCfgDtlDTOS.add(sysUlDatCfgDtlDTO);
                    afterApplyFileMap.put(sysUlDatCfgDtlDTO.getCfgDtlCd(), sysUlDatCfgDtlDTOS);
                }
            }
            /*for (String s : beforeApplyFileMap.keySet()) {
                //if (applyFileMap.containsKey(s)) {
                if (null != applyFileMap.get(s)) {
                    afterApplyFileList.addAll(applyFileMap.get(s));
                }
                //} else {
                if (null != beforeApplyFileMap.get(s)) {
                    afterApplyFileList.addAll(beforeApplyFileMap.get(s));
                }
                //}
            }*/

            //所有配置文件--无文件记录
            List<SysUlDatCfgDTO> cfgDTOList =this.uploadApiService.searchSysUlDatCfgList(ulDatCfgQueryCondition);
            List<SysUlDatCfgDtlDTO> cfgDtlDTOList = null;
            //List<SysUlDatCfgDtlDTO> noFileCfgDtlList = new ArrayList<>();
            List<SysUlDatCfgDtlDTO> resultCfgDtlDTO = new ArrayList<>();
            if (CollectionUtils.isNotEmpty(cfgDTOList)) {
                cfgDtlDTOList = cfgDTOList.get(0).getSysUlDatCfgDtlDTOList();

                for (SysUlDatCfgDtlDTO sysUlDatCfgDtlDTO : cfgDtlDTOList) {
                    if (afterApplyFileMap.containsKey(sysUlDatCfgDtlDTO.getCfgDtlCd()) && null != afterApplyFileMap.get(sysUlDatCfgDtlDTO.getCfgDtlCd())) {
                        resultCfgDtlDTO.addAll(afterApplyFileMap.get(sysUlDatCfgDtlDTO.getCfgDtlCd()));
                    } else {
                        resultCfgDtlDTO.add(sysUlDatCfgDtlDTO);
                    }
                    /*if (condition.getCfgCd().equals(sysUlDatCfgDtlDTO.getCfgCd())) {
                        if (null != applyFileMap.get(sysUlDatCfgDtlDTO.getCfgDtlCd()) && applyFileMap.containsKey(sysUlDatCfgDtlDTO.getCfgDtlCd())) {
                            resultCfgDtlDTO.addAll(applyFileMap.get(sysUlDatCfgDtlDTO.getCfgDtlCd()));
                        }
                        if (null != beforeApplyFileMap.get(sysUlDatCfgDtlDTO.getCfgDtlCd()) && beforeApplyFileMap.containsKey(sysUlDatCfgDtlDTO.getCfgDtlCd())) {
                            resultCfgDtlDTO.addAll(beforeApplyFileMap.get(sysUlDatCfgDtlDTO.getCfgDtlCd()));
                        }
                        resultCfgDtlDTO.add(sysUlDatCfgDtlDTO);
                    }*/
                }

                /*for (SysUlDatCfgDtlDTO sysUlDatCfgDtlDTO : cfgDtlDTOList) {
                    if (!hasFileCfgDtlCdList.contains(sysUlDatCfgDtlDTO.getCfgDtlCd())) {
                        noFileCfgDtlList.add(sysUlDatCfgDtlDTO);
                    }
                }*/
                Collections.sort(resultCfgDtlDTO, new Comparator<SysUlDatCfgDtlDTO>() {
                    @Override
                    public int compare(SysUlDatCfgDtlDTO o1, SysUlDatCfgDtlDTO o2) {
                        return o1.getSortNo().compareTo(o2.getSortNo());
                    }
                });

                for (SysUlDatCfgDTO dto : list) {
                    dto.setSysUlDatCfgDtlDTOList(resultCfgDtlDTO);
                }
            }

            /*for (SysUlDatCfgDTO dto : list) {
                dto.setSysUlDatCfgDtlDTOList(new ArrayList<>());
                for (SysUlDatCfgDtlDTO sysUlDatCfgDtlDTO : afterApplyFileList) {
                    if (StringUtils.isEmpty(sysUlDatCfgDtlDTO.getRecId())) {
                        continue;
                    }
                    if (CollectionUtils.isNotEmpty(deleteFilesIdList) && deleteFilesIdList.contains(sysUlDatCfgDtlDTO.getRecId())) {
                        continue;
                    }
                    if (dto.getCfgCd().equals(sysUlDatCfgDtlDTO.getCfgCd())) {
                        dto.getSysUlDatCfgDtlDTOList().add(sysUlDatCfgDtlDTO);
                    }
                }

                Collections.sort(dto.getSysUlDatCfgDtlDTOList(), new Comparator<SysUlDatCfgDtlDTO>() {
                    @Override
                    public int compare(SysUlDatCfgDtlDTO o1, SysUlDatCfgDtlDTO o2) {
                        return o1.getSortNo().compareTo(o2.getSortNo());
                    }
                });
            }*/
        }
        if (CollectionUtils.isNotEmpty(list)) {
            Map<String, String> audStsCdMap = this.sysDictionaryApiService.searchGroupToMap(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), CapitalConstant.CODE_MATE_AUD_STS_CD);
            voList = new ArrayList<>();
            PrjFileInfoVO vo;
            //设置路径
            String picServicePath = PropertiesCacheUtils.getProperty(cn.fl.upload.constant.UploadConstant.UPLOAD_SERVER_PATH);
            for (SysUlDatCfgDTO dto : list) {
                for (SysUlDatCfgDtlDTO dtlDTO : dto.getSysUlDatCfgDtlDTOList()) {
                    vo = new PrjFileInfoVO();
                    if(StringUtils.isNotEmpty(condition.getPkId())){
                        vo.setId(Long.valueOf(condition.getPkId()));//业务主键
                    }
                    vo.setCfgDtlCd(dtlDTO.getCfgDtlCd());//配置子编号
                    vo.setDatNm(dtlDTO.getDatNm());//配置名称
                    vo.setCfgCd(dtlDTO.getCfgCd());//配置编号
                    vo.setOrgCd(dtlDTO.getOrgCd());//配置组织架构代码
                    vo.setCfgNm(dto.getCfgNm());//配置子名称
                    vo.setIsMust(dtlDTO.getIsMust());//是否必传
                    vo.setMaxNum(dtlDTO.getMaxNum());//最大文件数量
                    //如果有HTTP开头说明是可以访问路径,无需干涉
                    if(StringUtils.isNotBlank(dtlDTO.getFilePath()) && !dtlDTO.getFilePath().startsWith("http") && StringUtils.isNotBlank(picServicePath)){
                        vo.setFilePath(picServicePath+dtlDTO.getFilePath());
                    }else{
                        vo.setFilePath(dtlDTO.getFilePath());
                    }
                    vo.setFileId(dtlDTO.getRecId());
                    vo.setFileNm(dtlDTO.getRecFileNm());//上传名称               vo.setFileId(dtlDTO.getRecId());//附件ID
                    vo.setCrtTm(dtlDTO.getRecCrtTm());//上传时间
                    if (StringUtils.isNotBlank(dtlDTO.getRecAudStsCd())) {
                        vo.setAudStsCd(dtlDTO.getRecAudStsCd());//验证状态
                    } else {
                        vo.setAudStsCd("0");//验证状态
                    }
                    if (audStsCdMap != null && audStsCdMap.containsKey(vo.getAudStsCd())) {
                        vo.setAudStsCdNm(audStsCdMap.get(vo.getAudStsCd()));
                    }
                    voList.add(vo);
                }
            }
        }
        return voList;
    }

    private List<PrjFileInfoVO> getPropUploadFileList(SysUlFilesRecQueryCondition condition) throws BaseException {
        //查询资料配置，系统代码,组织架构代码,配置编号 ,业务主键
        SysUlDatCfgQueryCondition ulDatCfgQueryCondition = new SysUlDatCfgQueryCondition();
        ulDatCfgQueryCondition.setSysCd(condition.getSysCd());//系统代码
        ulDatCfgQueryCondition.setOrgCd(condition.getOrgCd());
        ulDatCfgQueryCondition.setDataId(String.valueOf(condition.getPkId()));//业务主键
        ulDatCfgQueryCondition.setIsValid(BaseConstant.IS_YESNO_YES);
        List<String> cfgCdList = new ArrayList<>();
        cfgCdList.add(condition.getCfgCd());//配置编号
        ulDatCfgQueryCondition.setCfgCdList(cfgCdList);//配置编号集合
        List<SysUlDatCfgDTO> list = null ;
        if(StringUtils.isEmpty(condition.getPkId())){
            list =this.uploadApiService.searchSysUlDatCfgList(ulDatCfgQueryCondition);
        }else{
            list = this.uploadApiService.searchSysUlDatCfgListByDataId(ulDatCfgQueryCondition);
        }
        List<PrjFileInfoVO> voList = null;
        if (CollectionUtils.isNotEmpty(list)) {
            Map<String, String> audStsCdMap = this.sysDictionaryApiService.searchGroupToMap(cn.lionbridge.center.context.CurrentThreadContext.getCurrentSysCd(), cn.lionbridge.center.context.CurrentThreadContext.getCurrentOrgCd(), CapitalConstant.CODE_MATE_AUD_STS_CD);
            voList = new ArrayList<>();
            PrjFileInfoVO vo;
            //设置路径
            String picServicePath = PropertiesCacheUtils.getProperty(UploadConstant.UPLOAD_SERVER_PATH);
            for (SysUlDatCfgDTO dto : list) {
                for (SysUlDatCfgDtlDTO dtlDTO : dto.getSysUlDatCfgDtlDTOList()) {
                    vo = new PrjFileInfoVO();
                    if(StringUtils.isNotEmpty(condition.getPkId())) {
                        vo.setId(Long.valueOf(condition.getPkId()));//业务主键
                    }
                    vo.setCfgDtlCd(dtlDTO.getCfgDtlCd());//配置子编号
                    vo.setDatNm(dtlDTO.getDatNm());//配置名称
                    vo.setCfgCd(dtlDTO.getCfgCd());//配置编号
                    vo.setOrgCd(dtlDTO.getOrgCd());//配置组织架构代码
                    vo.setCfgNm(dto.getCfgNm());//配置子名称
                    vo.setFileId(dtlDTO.getRecId());//附件ID
                    //如果有HTTP开头说明是可以访问路径,无需干涉
                    if(StringUtils.isNotBlank(dtlDTO.getFilePath()) && !dtlDTO.getFilePath().startsWith("http") && StringUtils.isNotBlank(picServicePath)){
                        vo.setFilePath(picServicePath+dtlDTO.getFilePath());
                    }else{
                        vo.setFilePath(dtlDTO.getFilePath());
                    }
                    vo.setFileNm(dtlDTO.getRecFileNm());//上传名称
                    vo.setCrtTm(dtlDTO.getRecCrtTm());//上传时间
                    vo.setIsMust(dtlDTO.getIsMust());//是否必传
                    vo.setMaxNum(dtlDTO.getMaxNum());//最大上传数量
                    if (StringUtils.isNotBlank(dtlDTO.getRecAudStsCd())) {
                        vo.setAudStsCd(dtlDTO.getRecAudStsCd());//验证状态
                    } else {
                        vo.setAudStsCd("0");//验证状态
                    }

                    if (audStsCdMap != null && audStsCdMap.containsKey(vo.getAudStsCd())) {
                        vo.setAudStsCdNm(audStsCdMap.get(vo.getAudStsCd()));
                    }
                    voList.add(vo);
                }
            }
        }
        return voList;
    }


    @Deprecated
    private void checkLnkFiles(HttpServletRequest request) throws BaseException{
        String fileParams = request.getParameter("fileParams");
        String ownerCd = request.getParameter("ownerCd");
        String cfgCd;
        String sysCd;
        if (StringUtils.isEmpty(ownerCd) || !"1".equals(ownerCd)) {// 挂靠公司默认归属第三方
            cfgCd = LnkCompFileCfgEnum.PRJ029.getCode();
            sysCd = LnkCompFileCfgEnum.PRJ029.getSysCd();
        } else {
            if ("1".equals(ownerCd)) {
                cfgCd = LnkCompFileCfgEnum.PRJ030.getCode();
                sysCd = LnkCompFileCfgEnum.PRJ030.getSysCd();
            } else if ("2".equals(ownerCd)) {
                cfgCd = LnkCompFileCfgEnum.PRJ029.getCode();
                sysCd = LnkCompFileCfgEnum.PRJ029.getSysCd();
            } else {
                cfgCd = LnkCompFileCfgEnum.PRJ032.getCode();
                sysCd = LnkCompFileCfgEnum.PRJ032.getSysCd();
            }
        }
        SysUlDatCfgDtlQueryCondition ulDatCfgDtlQueryCondition = new SysUlDatCfgDtlQueryCondition();
        ulDatCfgDtlQueryCondition.setCfgCd(cfgCd);
        ulDatCfgDtlQueryCondition.setIsDel(BaseConstant.IS_YESNO_NO);
        ulDatCfgDtlQueryCondition.setSysCd(sysCd);
        ulDatCfgDtlQueryCondition.setOrgCd(SplSystemConstant.DEFAULT_ORG_CD);
        List<SysUlDatCfgDtlDTO> uploadCfgDtlDTOList = this.sysUlDatCfgDtlApiService.srearchSyUlDatCfgDtlList(ulDatCfgDtlQueryCondition);

        Map<String, Integer> fileCfgDtlCdAndNumMap = new HashMap<>();

        List<SysUlFilesRecVO> filesForPage = JSON.parseArray(fileParams, SysUlFilesRecVO.class);
        if (StringUtils.isEmpty(fileParams)) {
            throw new BaseException("请上传附件信息");
        } else {
            if (!(filesForPage.size() > 0)) {
                throw new BaseException("请上传附件信息");
            }
        }
        if (CollectionUtils.isNotEmpty(filesForPage)) {
            for (SysUlFilesRecVO sysUlFilesRecVO : filesForPage) {
                if (StringUtils.isEmpty(fileCfgDtlCdAndNumMap.get(sysUlFilesRecVO.getCfgDtlCd()))) {
                    fileCfgDtlCdAndNumMap.put(sysUlFilesRecVO.getCfgDtlCd(), 1);
                } else {
                    fileCfgDtlCdAndNumMap.put(sysUlFilesRecVO.getCfgDtlCd(), fileCfgDtlCdAndNumMap.get(sysUlFilesRecVO.getCfgDtlCd()) + 1);
                }
            }
        }

        for (SysUlDatCfgDtlDTO sysUlDatCfgDtlDTO : uploadCfgDtlDTOList) {
            //校验是否必传
            if (StringUtils.isNotEmpty(sysUlDatCfgDtlDTO.getIsMust()) && 1 == sysUlDatCfgDtlDTO.getIsMust()) {
                if (!fileCfgDtlCdAndNumMap.containsKey(sysUlDatCfgDtlDTO.getCfgDtlCd())) {
                    throw new BaseException("请上传" + sysUlDatCfgDtlDTO.getDatNm());
                }
            }

            //校验上传数量
            if (StringUtils.isNotEmpty(sysUlDatCfgDtlDTO.getMaxNum()) && 0 != sysUlDatCfgDtlDTO.getMaxNum()) {
                if (sysUlDatCfgDtlDTO.getMaxNum() < fileCfgDtlCdAndNumMap.get(sysUlDatCfgDtlDTO.getCfgDtlCd())) {
                    throw new BaseException(sysUlDatCfgDtlDTO.getDatNm() + "只能上传" + sysUlDatCfgDtlDTO.getMaxNum() + "份");
                }
            }
        }


    }

    /**
     * 到旧附件列表页面
     *
     */
    @RequestMapping(value = "/toOldFilesListPage.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView toOldFilesListPage(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView view = new ModelAndView("project/prjlnkcomp/projectLnkCompOldFilesList");
        String id = request.getParameter("id");
        view.addObject("id", id);
        BaseLogUtils.newWebLogger("跳转到挂靠公司旧附件列表页面").setLogOperType(LogOperEnum.REQ)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                .setWarning(false)
                .setKeys("id", id)
                .info();
        return view;
    }

    /**
     * 到三方数据页面
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "/toThreeDataPage.do", method = { RequestMethod.GET, RequestMethod.POST })
    public ModelAndView toThreeDataPage(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView view = new ModelAndView("project/prjlnkcomp/prjLnkTripartiteDataTab");
        String lnkId = request.getParameter("lnkId");
        String saveBizFlowRl = request.getParameter("saveBizFlowRl");

        List<SysDictionaryDTO> splOpTypCds = this.sysDictionaryApiService.searchGroupAll(SplSystemConstant.SPL_SYS_CD,SplSystemConstant.DEFAULT_ORG_CD, fl.spl.facade.framework.constant.DictionaryConstant.SPL_OP_TYP_CD);
        List<KeyValueVO> opTypCd = null ;
        if(CollectionUtils.isNotEmpty(splOpTypCds)){
            opTypCd = new ArrayList<>(splOpTypCds.size());
            for(SysDictionaryDTO dto : splOpTypCds){
                if(BaseConstant.IS_YESNO_YES == dto.getIsSysDef()){
                    KeyValueVO keyValueVO = new KeyValueVO();
                    keyValueVO.setKey(dto.getCode());
                    keyValueVO.setValue(dto.getCodeNm());
                    opTypCd.add(keyValueVO);
                }
            }
        }
        view.addObject("opTypCd", JSON.toJSON(opTypCd));

        List<KeyValueVO> signDesc = this.sysDictionaryApiService.getKvList(fl.spl.facade.framework.constant.DictionaryConstant.SPL_SIGN_DESC_CD,SplSystemConstant.SPL_SYS_CD,SplSystemConstant.DEFAULT_ORG_CD);
        view.addObject("signDesc", JSON.toJSON(signDesc));

        view.addObject("lnkId", lnkId);

        /*String isFlow = request.getParameter("isFlow");//是否在流程页面中打开
        view.addObject("isFlow", isFlow);*/

        String isWarnCheck = request.getParameter("isWarnCheck");
        view.addObject("isWarnCheck", isWarnCheck);
        view.addObject("saveBizFlowRl", saveBizFlowRl);

        /*String warnRecId = request.getParameter("warnRecId");// 高风险预警记录ID
        view.addObject("warnRecId", warnRecId);*/

        String isRiskWarnFlow = request.getParameter("isRiskWarnFlow");//是否是挂靠公司高风险复议流程审核节点
        if (StringUtils.isNotEmpty(isRiskWarnFlow)) {
            view.addObject("isRiskWarnFlow", isRiskWarnFlow);
        } else {
            view.addObject("isRiskWarnFlow", 0);
        }
        // 返回页面
        return view;
    }
    
    @RequestMapping(value = "/saveLoa.do", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object saveLoa(HttpServletRequest request, HttpServletResponse response) {
    	String isRecycleLoa = request.getParameter("isRecycleLoa");
		String isUploadLoa = request.getParameter("isUploadLoa");
		String lnkCompId = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "修改成功！");
		if(StringUtils.isEmpty(lnkCompId)){
			result.setInfo("主键ID不能为空");
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			return result ;
		}
		if(StringUtils.isEmpty(isUploadLoa) && StringUtils.isEmpty(isRecycleLoa)){
			result.setInfo("修改内容为空，修改失败");
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			return result ;
		}
		// 根据ID查询挂靠公司
		PrjLnkCompVO vo = new PrjLnkCompVO();
		if(StringUtils.isNotEmpty(isUploadLoa) && !"2".equals(isUploadLoa)){
			vo.setIsUploadLoa(Integer.valueOf(isUploadLoa));
		}
		if(StringUtils.isNotEmpty(isRecycleLoa) && !"2".equals(isRecycleLoa)){
			vo.setIsRecycleLoa(Integer.valueOf(isRecycleLoa));
		}
		vo.setId(Long.valueOf(lnkCompId));
		vo.setMdfTm(new Date());
		vo.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
		// 保存修改
		boolean b = this.prjLnkCompService.modifyLnkLoa(vo);
		if(!b){
			result.setInfo("修改失败！");
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			return result ;
		}
		
		return result ;
    }
    /**
     * 校验是否是狮桥员工
     */
    @RequestMapping(value = "/kingDeeWsCheckLnk.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object kingdeeWsCheck(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "获取成功");
        BaseLogUtils.newWebLogger("开始校验是否是狮桥员工：kingDeeWsCheckLnk").setLogOperType(LogOperEnum.RESP)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                .setWarning(false)
                .info();
        String rlPsnJSON = request.getParameter("rlPsnList");
        String splAttrCd = request.getParameter("splAttrCd");//供应商属性
        List<PrjLnkCompRlPsnVO> rlPsnList = new ArrayList<PrjLnkCompRlPsnVO>();
        if(null!=rlPsnJSON){
            rlPsnList = JSON.parseArray(rlPsnJSON, PrjLnkCompRlPsnVO.class);
        }
        if( rlPsnList.isEmpty() ){
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("联系人列表为空");
            return request;
        }
        //联系人类型
        Map<String,String> map = new HashMap<>();
        //联系人类型
        List<KeyValueVO> rlTypCDList;
        if ("1".equals(splAttrCd)) {
            rlTypCDList = this.splNpSocialRlService.searchRlTypCdList(DictionaryConstant.CODE_GRP_RL_TYP_CD);
        } else {
            rlTypCDList = this.splRlPsnService.searchRlTypCdList();
        }
        for(KeyValueVO kv : rlTypCDList  ){
            map.put(kv.getKey(),kv.getValue());
        }
        String resultPhone ="";
        for( PrjLnkCompRlPsnVO rlInfo : rlPsnList ){
            resultPhone = iKingDeeWsInfoService.getPhoneNum(rlInfo.getTel());
            if( StringUtils.isBlank(resultPhone) ){
//                result.setSuccess(BaseConstant.IS_YESNO_NO);
//                result.setInfo("金蝶接口调用失败");
                return result;
            }
            BaseLogUtils.newWebLogger("获取金蝶接口数据getPhone"+resultPhone).setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();
            ArrayList<KingDeeWsInfoDTO> infos = JSON.parseObject(resultPhone, new TypeReference<ArrayList<KingDeeWsInfoDTO>>(){});
            if( infos.size()>1 ){//证明有多个事业部
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo("["+map.get(rlInfo.getRlTypCd())+":"+rlInfo.getRlNm()+"]"+"手机号/证件号为狮桥内部员工："+infos.get(0).getDepartmentName()+"/"+infos.get(0).getUserName()+"，禁止维护，请重新填写");
                return result;
            }else {
                for ( KingDeeWsInfoDTO info : infos){
                    if( StringUtils.isNotBlank(info.getUserCode()) ) {
                        result.setSuccess(BaseConstant.IS_YESNO_NO);
                        result.setInfo("["+map.get(rlInfo.getRlTypCd())+":"+rlInfo.getRlNm()+"]"+"手机号/证件号为狮桥内部员工：" + info.getDepartmentName() + "/" + info.getUserName() + "，禁止维护，请重新填写");
                        return result;
                    }
                }
            }
        }
        String resultIdCard ="";
        for( PrjLnkCompRlPsnVO rlInfo : rlPsnList ){
            resultIdCard = iKingDeeWsInfoService.getIdentityNum(rlInfo.getCertNo());
            if( StringUtils.isBlank(resultIdCard) ){
//                result.setSuccess(BaseConstant.IS_YESNO_NO);
//                result.setInfo("金蝶接口调用失败");
                return result;
            }
            BaseLogUtils.newWebLogger("获取金蝶接口数据getIdCard："+resultIdCard).setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();
            ArrayList<KingDeeWsInfoDTO> infos = JSON.parseObject(resultIdCard, new TypeReference<ArrayList<KingDeeWsInfoDTO>>(){});
            if( infos.size()>1 ){//证明有多个事业部
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo("["+map.get(rlInfo.getRlTypCd())+":"+rlInfo.getRlNm()+"]"+"手机号/证件号为狮桥内部员工："+infos.get(0).getDepartmentName()+"/"+infos.get(0).getUserName()+"，禁止维护，请重新填写");
                return result;
            }else {
                for ( KingDeeWsInfoDTO info : infos){
                    if( StringUtils.isNotBlank(info.getUserCode()) ) {
                        result.setSuccess(BaseConstant.IS_YESNO_NO);
                        result.setInfo("["+map.get(rlInfo.getRlTypCd())+":"+rlInfo.getRlNm()+"]"+"手机号/证件号为狮桥内部员工：" + info.getDepartmentName() + "/" + info.getUserName() + "，禁止维护，请重新填写");
                        return result;
                    }
                }
            }
        }
        return result;
    }

    private SplCommPropInfoVO getPropInfoVO(HttpServletRequest request){
        String propCd = request.getParameter("propCd");
        String validTmStar = request.getParameter("validTmStar");
        String validTmEnd = request.getParameter("validTmEnd");
        String roadBicycleRate = request.getParameter("roadBicycleRate");
        String stopTruckRate = request.getParameter("stopTruckRate");
        String fileParams = request.getParameter("propFileParams");
        if(StringUtils.isNotEmpty(propCd)){
            if(StringUtils.isEmpty(validTmStar)){
                throw new BaseException(BaseExceptionConstant.COMMON_0001, "请填写协议担保有效期！");
            }
            if(StringUtils.isEmpty(validTmEnd)){
                throw new BaseException(BaseExceptionConstant.COMMON_0001, "请填写协议担保有效期！");
            }
            if (StringUtils.isNotBlank(fileParams)) {
                List<PrjFileInfoVO> fileParamList = JSON.parseArray(fileParams, PrjFileInfoVO.class);
                if(CollectionUtils.isNotEmpty(fileParamList)){
                    BaseLogUtils.newLogger("附件信息").setKeys("fileParamList.size()",fileParamList.size()+"").info();
                    List<SysUlFilesRecVO> fileList = new ArrayList<>(fileParamList.size());
                    SysUlFilesRecVO filesRecVO ;
                    List<String> cfgDtlList = new ArrayList<>();
                    for (PrjFileInfoVO fileInfoVO : fileParamList) {
                        cfgDtlList.add(fileInfoVO.getCfgDtlCd());
                    }
                    for (PrjFileInfoVO fileInfoVO : fileParamList) {
                        filesRecVO = new SysUlFilesRecVO();
                        if (StringUtils.isNotEmpty(fileInfoVO.getFileId())) {
                            filesRecVO.setId(fileInfoVO.getFileId());
                        }
                        filesRecVO.setFilePath(fileInfoVO.getFilePath());
                        filesRecVO.setFileNm(fileInfoVO.getFileNm());
                        filesRecVO.setCfgCd(SplInfoFileCfgEnum.PRJ034.getCode());
                        filesRecVO.setTabNm(SplInfoFileCfgEnum.PRJ034.getTableNm());
                        filesRecVO.setSysCd(SplInfoFileCfgEnum.PRJ034.getSysCd());
                        filesRecVO.setCfgDtlCd(fileInfoVO.getCfgDtlCd());
                        filesRecVO.setOrgCd(fileInfoVO.getOrgCd());
                        filesRecVO.setAbsLocPath(PropertiesCacheUtils.getProperty(SplInfoFileCfgEnum.PRJ034.getUploadRootPath())+filesRecVO.getFilePath());
                        filesRecVO.setCrtTm(new Date());
                        filesRecVO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
                        filesRecVO.setIsDel(BaseConstant.IS_YESNO_NO);
                        //默认验证状态:未验证
                        filesRecVO.setAudStsCd(PropertiesCacheUtils.getProperty(fl.constant.facade.framework.constant.DictionaryConstant.CODE_GRP_VALID_STATUS_CD_A));
                        fileList.add(filesRecVO);
                    }
                }else{
                    throw new BaseException(BaseExceptionConstant.COMMON_0001, "请上传附件信息！");
                }
            }else{
                throw new BaseException(BaseExceptionConstant.COMMON_0001, "请上传附件信息！");
            }
        }
        return null ;
    }

    /**
     * 根据挂靠公司id查询挂靠公司账号
     */
    @SuppressWarnings("unchecked")
    @RequestMapping(value = "/queryBankList.do", method = { RequestMethod.GET})
    @ResponseBody
    public Object queryBankList(HttpServletRequest request, HttpServletResponse response) {
        ListPageVO<PrjLnkCompBkAccDTO> listPage = null;
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "获取成功");
        try {
            String currentPage = request.getParameter("page");
            String pageSize = request.getParameter("pagesize");

            String lnkCompId = request.getParameter("lnkCompId");
            String rcptUnt = request.getParameter("rcptUnt");
            String purpCd = request.getParameter("purpCd");
            String compensatoryType = request.getParameter("compensatoryType");


            Pager page = new Pager();
            if (StringUtils.isNotEmpty(currentPage)) {
                page.setCurrentPage(Integer.parseInt(currentPage));
            }
            if (StringUtils.isNotEmpty(pageSize)) {
                page.setEveryPage(Integer.parseInt(pageSize));
            }
            PrjLnkCompBkAccQC qc = new PrjLnkCompBkAccQC();
            if (StringUtils.isNotBlank(lnkCompId)) {
                qc.setLnkCompId(Long.valueOf(lnkCompId));
            }
            if (StringUtils.isNotBlank(rcptUnt)) {
                qc.setRcptUnt(rcptUnt);
            }
            qc.setAudStsCd(FlowConstant.FLOW_CHECK_STATE_PASS);
            qc.setPurpCd(purpCd);
            if ("1".equals(compensatoryType)) {
                qc.setIsSelectGuar(1);
            }
            page.setCondition(qc);
            Pager pager = this.prjLnkCompQueryApiService.searchLnkBkListPage(page, "11000", "0000");
            List<PrjLnkCompBkAccDTO> list = (List<PrjLnkCompBkAccDTO>) pager.getResultList();
            listPage = new ListPageVO<PrjLnkCompBkAccDTO>(list, pager.getTotalCount());
            BaseLogUtils.newWebLogger("获取挂靠公司开户银行信息数据").setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.KCRZ_HELPER_APP_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setKeys("resultPage", JSON.toJSONString(listPage))
                    .info();
        } catch (BaseException e) {
            logger.error("获取挂靠公司账号数据失败！", e);
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(e.getMessage());
            return result;
        } catch (Exception e) {
            logger.error("获取挂靠公司账号数据失败！", e);
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("获取挂靠公司账号数据失败");
            return result;
        }
        return listPage;
    }
    /*
     * 校验是否是狮桥员工
     */
    @RequestMapping(value = "/modifyRate.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object modifyRate(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES);
        String stopTruckRate = request.getParameter("stopTruckRate");
        String roadBicycleRate = request.getParameter("roadBicycleRate");
        String lnkCompId = request.getParameter("lnkCompId");
        String isApply = request.getParameter("isApply");
        SplCarsGuarDtlInfoQC carsGuarQC = new SplCarsGuarDtlInfoQC();
        carsGuarQC.setIsDel(BaseConstant.IS_YESNO_NO);
        carsGuarQC.setLnkId(Long.valueOf(lnkCompId));
        if(StringUtils.isNotEmpty(isApply) && BaseConstant.IS_YESNO_YES_STR.equals(isApply)){
            carsGuarQC.setIsValid(2);
        }else{
            carsGuarQC.setIsValid(BaseConstant.IS_YESNO_YES);
        }
        List<SplCarsGuarDtlInfoDTO> carsGuarDtlInfoDTOS = this.splCarsGuarDtlInfoApiService.searchList(carsGuarQC);
        if(CollectionUtils.isNotEmpty(carsGuarDtlInfoDTOS)){
            SplCarsGuarDtlInfoDTO carsGuarDTO = carsGuarDtlInfoDTOS.get(0);
            DecimalFormat df = new DecimalFormat("#.00");
            if(StringUtils.isNotEmpty(roadBicycleRate)) {
                carsGuarDTO.setRoadBicycleRate(Double.valueOf(df.format(Double.valueOf(roadBicycleRate))));
            }
            if(StringUtils.isNotEmpty(stopTruckRate)) {
                carsGuarDTO.setStopTruckRate(Double.valueOf(df.format(Double.valueOf(stopTruckRate))));
            }
            carsGuarDTO.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
            carsGuarDTO.setMdfTm(new Date());
            boolean b = this.splCarsGuarDtlInfoApiService.modify(carsGuarDTO);
            if(!b){
                result.setInfo("修改失败！");
                result.setSuccess(BaseConstant.IS_YESNO_NO);
            }
        }

        return result ;
    }
}

